mirror of
https://github.com/nix-community/disko
synced 2024-09-20 05:51:54 +00:00
fix: add package build and fix disko
This commit is contained in:
parent
f82656afbd
commit
2a59af78a8
3 changed files with 34 additions and 2 deletions
15
Makefile
Normal file
15
Makefile
Normal file
|
@ -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)
|
12
disko
12
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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue