summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile15
-rwxr-xr-xdisko12
-rw-r--r--flake.nix9
3 files changed, 34 insertions, 2 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..d01f5bf
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,15 @@
+PREFIX ?= /usr/local
+SHARE ?= $(PREFIX)/share/disko
+
+all:
+
+SOURCES = disko cli.nix default.nix types.nix
+
+install:
+ mkdir -p $(PREFIX)/bin $(SHARE)
+ sed \
+ -e "s|libexec_dir=\".*\"|libexec_dir=\"$(SHARE)\"|" \
+ -e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \
+ disko > $(PREFIX)/bin/disko
+ chmod 755 $(PREFIX)/bin/disko
+ cp -r $(SOURCES) $(SHARE)
diff --git a/disko b/disko
index c5b9d49..f51339e 100755
--- a/disko
+++ b/disko
@@ -1,9 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
-set -x
readonly libexec_dir="${0%/*}"
+# a file with the disko config
+declare disko_config
+
# mount was chosen as the default mode because it's less destructive
mode=mount
nix_args=()
@@ -30,6 +32,11 @@ abort() {
## Main ##
+[[ $# -eq 0 ]] && {
+ showUsage
+ exit 1
+}
+
while [[ $# -gt 0 ]]; do
case "$1" in
-m | --mode)
@@ -46,10 +53,11 @@ while [[ $# -gt 0 ]]; do
exit 0
;;
*)
- if [ -z ${disko_config+x} ] && [ -e $1 ]; then
+ if [ -z ${disko_config+x} ] && [ -e "$1" ]; then
disko_config=$1
else
showUsage
+ exit 1
fi
;;
esac
diff --git a/flake.nix b/flake.nix
index c06834f..adb2add 100644
--- a/flake.nix
+++ b/flake.nix
@@ -8,6 +8,15 @@
lib = import ./. {
inherit (nixpkgs) lib;
};
+ packages.x86_64-linux.disko = let
+ pkgs = nixpkgs.legacyPackages.x86_64-linux;
+ in pkgs.stdenv.mkDerivation {
+ name = "disko";
+ src = ./.;
+ meta.description = "Format disks with nix-config";
+ installFlags = [ "PREFIX=$(out)" ];
+ };
+ packages.x86_64-linux.default = self.packages.x86_64-linux.disko;
checks.x86_64-linux = let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in