St: Difference between revisions

imported>Lubsch
m currected "prev" to "super"
DoggoBit (talk | contribs)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Lowercase title}}
{{DISPLAYTITLE:st}}
[[Category:Applications]]
[[Category:Applications]]


Line 44: Line 44:
Followed by:
Followed by:


<syntaxhighlight>
<syntaxhighlight lang=console>
$ nix-env -i -f my-custom-st
$ nix-env -i -f my-custom-st
</syntaxhighlight>
</syntaxhighlight>
Line 56: Line 56:
To apply a patch you need to obtain the hash, the hash should be obtained with the following command
To apply a patch you need to obtain the hash, the hash should be obtained with the following command


<syntaxhighlight lang="sh">
<syntaxhighlight lang="console">
$ nix-prefetch-url <url>
$ nix-prefetch-url <url>
</syntaxhighlight>
</syntaxhighlight>
example
example
<syntaxhighlight lang="sh">
<syntaxhighlight lang="console">
$ nix-prefetch-url https://st.suckless.org/patches/rightclickpaste/st-rightclickpaste-0.8.2.diff
$ nix-prefetch-url https://st.suckless.org/patches/rightclickpaste/st-rightclickpaste-0.8.2.diff
</syntaxhighlight>
</syntaxhighlight>
Line 183: Line 183:
   ];
   ];
</syntaxhighlight>
</syntaxhighlight>
== Using a custom flake ==
Another way to patch and configure suckless software is by using a flake. The patches are inputs of the flake which is why their hashes don't have to be manually specified.
<syntaxhighlight lang="nix">
{
  description = "st with the alpha patch and a custom config";
  inputs = {
    nixpkgs.url = "nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
    # alpha patch
    alpha = {
      url = "https://st.suckless.org/patches/alpha/st-alpha-20220206-0.8.5.diff";
      flake = false;
    };
  };
  outputs = { self, nixpkgs, flake-utils, alpha }:
    flake-utils.lib.eachDefaultSystem (system: rec {
      # Create the  overlay
      overlays.default = self: super: {
        st = super.st.overrideAttrs (oldAttrs: rec {
          patches = [ alpha ];
          configFile = super.writeText "config.h" (builtins.readFile ./st-config.h);
          postPatch = ''
            ${oldAttrs.postPatch}
            cp ${configFile} config.def.h
          '';
        });
      };
      # Append the overlay to nixpkgs and output the new st package
      packages.default = (nixpkgs.legacyPackages.${system}.appendOverlays [ overlays.default ]).st;
    });
}
</syntaxhighlight>
The overlay is also an output of the flake and can be consumed by other flakes like a system configuration.


== Remote config ==
== Remote config ==
Line 267: Line 228:
</nowiki>}}
</nowiki>}}


<syntaxhighlight lang="sh">
<syntaxhighlight lang="console">
nix-shell st-test.nix
$ nix-shell st-test.nix
unpackPhase
$ unpackPhase
ls
$ ls
cd theunpackeddir
$ cd theunpackeddir
patchPhase
$ patchPhase
</syntaxhighlight>
</syntaxhighlight>
[https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases Additional phases]
[https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases Additional phases]