diff options
author | David Arnold <david.arnold@iohk.io> | 2022-11-05 14:25:08 -0500 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2022-11-09 12:21:24 +0100 |
commit | 2a59af78a8e2e7ab6fc7a4be3671da0c19a8806c (patch) | |
tree | 8b26f8d4e15ac9d118350084516b99ff6e182fdd | |
parent | f82656afbd5dafe1a0f762bdb7678a62203158b0 (diff) |
fix: add package build and fix disko
-rw-r--r-- | Makefile | 15 | ||||
-rwxr-xr-x | disko | 12 | ||||
-rw-r--r-- | flake.nix | 9 |
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) @@ -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 @@ -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 |