From e40fcc145a5c99667e4369a17353a33cfa9b6ef9 Mon Sep 17 00:00:00 2001 From: Simon Parri Date: Thu, 29 May 2025 22:50:18 -0500 Subject: Move mkThinShim to new personal library --- hosts/ades/iso.nix | 6 +++--- hosts/ades/thin-shim.nix | 41 ----------------------------------------- hosts/default.nix | 1 + lib/default.nix | 4 ++++ lib/thin-shim.nix | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 44 deletions(-) delete mode 100644 hosts/ades/thin-shim.nix create mode 100644 lib/default.nix create mode 100644 lib/thin-shim.nix diff --git a/hosts/ades/iso.nix b/hosts/ades/iso.nix index 79db210..a0bd2e5 100644 --- a/hosts/ades/iso.nix +++ b/hosts/ades/iso.nix @@ -1,4 +1,4 @@ -{ modulesPath, lib, config, pkgs, ... }: +{ modulesPath, lib, tlib, config, pkgs, ... }: let inherit (lib.attrsets) @@ -6,6 +6,8 @@ let inherit (builtins) map; + mkThinShim = tlib.mkThinShim pkgs; + shimmedPackages = [ "wesnoth" "luanti" @@ -17,8 +19,6 @@ let "taisei" "unvanquished" ]; - - mkThinShim = import ./thin-shim.nix pkgs; in rec { imports = [ diff --git a/hosts/ades/thin-shim.nix b/hosts/ades/thin-shim.nix deleted file mode 100644 index a9f931b..0000000 --- a/hosts/ades/thin-shim.nix +++ /dev/null @@ -1,41 +0,0 @@ -pkgs: -let - inherit (builtins) - map elem; - - inherit (pkgs) stdenv; -in -pkg: inst: -stdenv.mkDerivation { - pname = pkg.pname + "-shim"; - version = pkg.version; - nativeBuildInputs = [pkg]; - dontUnpack = true; - buildPhase = '' -if [ -d ${pkg}/bin ]; then - mkdir -p "$out/bin" - for exe in $(ls "${pkg}/bin/"); do - cat >"$out/bin/$exe" </dev/null 2>&1 || term=xterm - -if [ "\$DISPLAY" ]; then - \$term -e nix shell '${inst}' --command '$exe' \$* -else - nix shell '${inst}' --command '$exe' \$* -fi -EOF - chmod +x "$out/bin/$exe" - done -fi - -for dir in "share/applications" "share/icons"; do - if [ -d "${pkg}/$dir" ]; then - mkdir -p "$out/$dir" - cp -a "${pkg}/$dir/"* "$out/$dir" - fi -done -''; -} diff --git a/hosts/default.nix b/hosts/default.nix index d5770c6..8ba60fb 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -9,6 +9,7 @@ let modules = [ ../modules ../users ] ++ modules; specialArgs = { inherit hostname inputs; + tlib = import ../lib { }; }; }; }; diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..0f6f82b --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,4 @@ +{ }: +{ + mkThinShim = import ./thin-shim.nix; +} diff --git a/lib/thin-shim.nix b/lib/thin-shim.nix new file mode 100644 index 0000000..a9f931b --- /dev/null +++ b/lib/thin-shim.nix @@ -0,0 +1,41 @@ +pkgs: +let + inherit (builtins) + map elem; + + inherit (pkgs) stdenv; +in +pkg: inst: +stdenv.mkDerivation { + pname = pkg.pname + "-shim"; + version = pkg.version; + nativeBuildInputs = [pkg]; + dontUnpack = true; + buildPhase = '' +if [ -d ${pkg}/bin ]; then + mkdir -p "$out/bin" + for exe in $(ls "${pkg}/bin/"); do + cat >"$out/bin/$exe" </dev/null 2>&1 || term=xterm + +if [ "\$DISPLAY" ]; then + \$term -e nix shell '${inst}' --command '$exe' \$* +else + nix shell '${inst}' --command '$exe' \$* +fi +EOF + chmod +x "$out/bin/$exe" + done +fi + +for dir in "share/applications" "share/icons"; do + if [ -d "${pkg}/$dir" ]; then + mkdir -p "$out/$dir" + cp -a "${pkg}/$dir/"* "$out/$dir" + fi +done +''; +} -- cgit v1.2.3