diff --git a/Makefile b/Makefile
index 56a5207..975f357 100644
--- a/Makefile
+++ b/Makefile
@@ -14,20 +14,15 @@ install: build
sudo install -m644 walrs.1 /usr/share/man/man1/
bash ./autocomplete.sh
-nix: build
- install -Dm755 target/release/walrs $(PREFIX)/bin/walrs
- mkdir -p <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mi>P</mi><mi>R</mi><mi>E</mi><mi>F</mi><mi>I</mi><mi>X</mi><mo stretchy="false">)</mo><mo>/</mo><mi>e</mi><mi>t</mi><mi>c</mi><mo>/</mo><mi>w</mi><mi>a</mi><mi>l</mi><mi>r</mi><mi>s</mi><mo>/</mo><mi>t</mi><mi>e</mi><mi>m</mi><mi>p</mi><mi>l</mi><mi>a</mi><mi>t</mi><mi>e</mi><mi>s</mi><mo>/</mo></mrow></math>(PREFIX)/etc/walrs/scripts/ $(PREFIX)/etc/walrs/colorschemes/
- cp -r templates/* $(PREFIX)/etc/walrs/templates/
- cp -r scripts/* $(PREFIX)/etc/walrs/scripts/
- cp -r colorschemes/* $(PREFIX)/etc/walrs/colorschemes/
- install -Dm644 walrs.1 $(PREFIX)/share/man/man1/
- bash ./autocomplete.sh
-
-uninstall:
- sudo rm -rf /usr/bin/walrs /etc/walrs ~/.config/walrs/ /usr/share/man/man1/walrs.1
-clean:
+nix:
+ nix build
+ sudo cp ./result/bin/walrs /usr/bin/walrs
+ sudo mkdir -p /etc/walrs
+ sudo cp -r ./result/etc/walrs/* /etc/walrs/
+ sudo cp ./result/share/man/man1/walrs.1 /usr/share/man/man1/walrs.1clean:
cargo clean
+
.PHONY: all build install uninstall clean nix
diff --git a/flake.nix b/flake.nix
index 215226c..41b2498 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,7 +15,6 @@
src = ./.;
cargoHash = "sha256-ItjbG/fPAW1mDJI5JXZ73L4c3UeDZzjBdADsyWhqzm8=";
-
nativeBuildInputs = with pkgs; [ bash ];
# Allow unstable Rust features
@@ -23,8 +22,9 @@
export RUSTC_BOOTSTRAP=1
'';
- # Let rustPlatform handle the binary, we just add the extra files
+ # Install everything to the Nix store first
postInstall = ''
+ # Install config files to result/
mkdir -p $out/etc/walrs/{templates,scripts,colorschemes}
if [ -d "templates" ]; then
@@ -37,6 +37,7 @@
cp -r colorschemes/* $out/etc/walrs/colorschemes/ || true
fi
+ # Install man page
if [ -f "walrs.1" ]; then
install -Dm644 walrs.1 $out/share/man/man1/walrs.1
fi
@@ -48,5 +49,31 @@
homepage = "https://github.com/pixel2175/walrs";
};
};
+
+ # Create installer that copies from result/ to system locations
+ packages.install-system = pkgs.writeShellScriptBin "walrs-install-system" ''
+ set -e
+ WALRS_PACKAGE="<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mrow><mi>s</mi><mi>e</mi><mi>l</mi><mi>f</mi><mo>.</mo><mi>p</mi><mi>a</mi><mi>c</mi><mi>k</mi><mi>a</mi><mi>g</mi><mi>e</mi><mi>s</mi><mo>.</mo></mrow></mrow></math>{system}.default}"
+
+ echo "Installing walrs from Nix store to system locations..."
+
+ # Install binary
+ sudo install -m755 "$WALRS_PACKAGE/bin/walrs" /usr/local/bin/walrs
+
+ # Install config files from result/etc/walrs/ to /etc/walrs/
+ sudo mkdir -p /etc/walrs
+ if [ -d "$WALRS_PACKAGE/etc/walrs" ]; then
+ sudo cp -r "$WALRS_PACKAGE/etc/walrs"/* /etc/walrs/
+ fi
+
+ # Install man page
+ if [ -f "$WALRS_PACKAGE/share/man/man1/walrs.1" ]; then
+ sudo install -Dm644 "$WALRS_PACKAGE/share/man/man1/walrs.1" /usr/share/man/man1/walrs.1
+ fi
+
+ echo "✓ walrs installed to /usr/local/bin/walrs"
+ echo "✓ Configuration files installed to /etc/walrs/"
+ echo "✓ Man page installed to /usr/share/man/man1/walrs.1"
+ '';
});
}