St: Difference between revisions

imported>Legendofmiracles
m removes a few of the `1`'s as they really are unnecessary and only clutter things up
DoggoBit (talk | contribs)
No edit summary
 
(9 intermediate revisions by 5 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 51: Line 51:


Most customization of <code>st</code> that alters its base feature set comes in the form of applying patches to the source code.
Most customization of <code>st</code> that alters its base feature set comes in the form of applying patches to the source code.
=== Obtaining hashes ===
To apply a patch you need to obtain the hash, the hash should be obtained with the following command
<syntaxhighlight lang="console">
$ nix-prefetch-url <url>
</syntaxhighlight>
example
<syntaxhighlight lang="console">
$ nix-prefetch-url https://st.suckless.org/patches/rightclickpaste/st-rightclickpaste-0.8.2.diff
</syntaxhighlight>


=== Patches ===
=== Patches ===
Line 129: Line 141:
   }))
   }))
];</syntaxhighlight>
];</syntaxhighlight>
== Using DWM ==


However, this will not work for <code>dwm</code>.  (Probably <code>services.xserver.windowManager.dwm</code> can only see the <code>dwm</code> in <code>pkgs</code>, not the one in <code>environment.systemPackages</code>.)  But you can use an overlay, like this:
However, this will not work for <code>dwm</code>.  (Probably <code>services.xserver.windowManager.dwm</code> can only see the <code>dwm</code> in <code>pkgs</code>, not the one in <code>environment.systemPackages</code>.)  But you can use an overlay, like this:
Line 141: Line 155:
       configFile = super.writeText "config.h" (builtins.readFile ./dwm-config.h);
       configFile = super.writeText "config.h" (builtins.readFile ./dwm-config.h);
       postPatch = oldAttrs.postPatch or "" + "\necho 'Using own config file...'\n cp ${configFile} config.def.h";
       postPatch = oldAttrs.postPatch or "" + "\necho 'Using own config file...'\n cp ${configFile} config.def.h";
      });
    })
  ];
</syntaxhighlight>
It should also be mentioned that the <code>st.overrideAttrs</code> should be added to the overlays when using <code>dwm</code> with dwm changes and st changes the overlay could look like this
<syntaxhighlight lang="nix">
nixpkgs.overlays = [
  (self: super: {
    dwm = super.dwm.overrideAttrs (oldAttrs: rec {
      patches = [
        ./path/to/my-dwm-patch.patch
        ];
      configFile = super.writeText "config.h" (builtins.readFile ./dwm-config.h);
      postPatch = oldAttrs.postPatch or "" + "\necho 'Using own config file...'\n cp ${configFile} config.def.h";
      });
    })
    st = super.st.overrideAttrs (oldAttrs: rec {
      patches = [
        ./path/to/my-dwm-patch.patch
        ];
      configFile = super.writeText "config.h" (builtins.readFile ./st-config.h);
      postPatch = "${oldAttrs.postPatch}\ncp ${configFile} config.def.h\n"
       });
       });
     })
     })
Line 166: Line 204:
     buildInputs = oldAttrs.buildInputs ++ [ harfbuzz ];
     buildInputs = oldAttrs.buildInputs ++ [ harfbuzz ];
   # If you want it to be always up to date use fetchTarball instead of fetchFromGitHub
   # If you want it to be always up to date use fetchTarball instead of fetchFromGitHub
   # src = pkgs.fetchTarball {
   # src = builtins.fetchTarball {
   #  url = "https://github.com/lukesmithxyz/st/archive/master.tar.gz";
   #  url = "https://github.com/lukesmithxyz/st/archive/master.tar.gz";
   # };
   # };
Line 190: 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]