St: Difference between revisions

imported>Artturin
add to applications and use lowercase title
DoggoBit (talk | contribs)
No edit summary
 
(15 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Lowercase title}}
{{DISPLAYTITLE:st}}
[[Category:Applications]]
[[Category:Applications]]


<code>st</code> the suckless terminal or the simple terminal
<code>st</code> the suckless terminal or the simple terminal
most things here apply for dwm and other suckless software too


The examples below only assume you are running Linux (at the time of this writing, darwin/OS X does not support <code>st</code>).
The examples below only assume you are running Linux (at the time of this writing, darwin/OS X does not support <code>st</code>).
Line 42: 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 49: 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 67: Line 81:
       # Or from any other source
       # Or from any other source
       (fetchpatch {
       (fetchpatch {
         url = "https://raw.githubusercontent.com/fooUser/barRepo/1111111111111111111111111111111111111111/somepatch.diff";
         url = "https://raw.githubusercontent.com/fooUser/barRepo/1111111/somepatch.diff";
         sha256 = "222222222222222222222222222222222222222222";
         sha256 = "222222222222222222222222222222222222222222";
       })
       })
Line 104: Line 118:
     # Or one pulled from GitHub
     # Or one pulled from GitHub
     # configFile = writeText "config.def.h" (builtins.readFile "${fetchFromGitHub { owner = "LukeSmithxyz"; repo = "st"; rev = "8ab3d03681479263a11b05f7f1b53157f61e8c3b"; sha256 = "1brwnyi1hr56840cdx0qw2y19hpr0haw4la9n0rqdn0r2chl8vag"; }}/config.h");
     # configFile = writeText "config.def.h" (builtins.readFile "${fetchFromGitHub { owner = "LukeSmithxyz"; repo = "st"; rev = "8ab3d03681479263a11b05f7f1b53157f61e8c3b"; sha256 = "1brwnyi1hr56840cdx0qw2y19hpr0haw4la9n0rqdn0r2chl8vag"; }}/config.h");
     postPatch = oldAttrs.postPatch ++ ''cp ${configFile} config.def.h'';
     postPatch = "${oldAttrs.postPatch}\n cp ${configFile} config.def.h";
   }))
   }))
];</syntaxhighlight>
];</syntaxhighlight>
Line 127: 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:
<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";
      });
    })
  ];
</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"
      });
    })
  ];
</syntaxhighlight>


== Remote config ==
== Remote config ==
Line 148: 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";
   # };
   # };
   }))
   }))
];</syntaxhighlight>
];</syntaxhighlight>
== Troubleshooting ==
=== See files after patching ===
{{file|st-test.nix|nix|
with import <nixpkgs> {};
<nowiki>
(st.overrideAttrs (oldAttrs: rec {
  buildInputs = oldAttrs.buildInputs ++ [ harfbuzz ];
  patches = [
    (fetchpatch {
      url = "https://st.suckless.org/patches/ligatures/0.8.3/st-ligatures-20200430-0.8.3.diff";
      sha256 = "18fllssg5d5gik1x0ppz232vdphr0y2j5z8lhs5j9zjs8m9ria5w";
    })
  ];
}))
</nowiki>}}
<syntaxhighlight lang="console">
$ nix-shell st-test.nix
$ unpackPhase
$ ls
$ cd theunpackeddir
$ patchPhase
</syntaxhighlight>
[https://nixos.org/manual/nixpkgs/stable/#sec-stdenv-phases Additional phases]