mirror of
https://github.com/nix-community/disko
synced 2024-11-14 16:17:06 +00:00
disko2: Add flake-output and package
This allows running `nix run .#disko2` for testing
This commit is contained in:
parent
62581f38f5
commit
f34c39ec45
5 changed files with 48 additions and 1 deletions
|
@ -32,6 +32,8 @@
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
disko = pkgs.callPackage ./package.nix { diskoVersion = version; };
|
disko = pkgs.callPackage ./package.nix { diskoVersion = version; };
|
||||||
|
disko2 = pkgs.callPackage ./package-disko2.nix { diskoVersion = version; };
|
||||||
|
|
||||||
# alias to make `nix run` more convenient
|
# alias to make `nix run` more convenient
|
||||||
disko-install = self.packages.${system}.disko.overrideAttrs (_old: {
|
disko-install = self.packages.${system}.disko.overrideAttrs (_old: {
|
||||||
name = "disko-install";
|
name = "disko-install";
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
use libexec-dir.nu
|
||||||
|
|
||||||
alias nix = ^nix --extra-experimental-features nix-command --extra-experimental-features flakes
|
alias nix = ^nix --extra-experimental-features nix-command --extra-experimental-features flakes
|
||||||
alias nix-eval-expr = nix eval --impure --json --expr
|
alias nix-eval-expr = nix eval --impure --json --expr
|
||||||
|
|
||||||
def eval-config [args: record]: nothing -> record {
|
def eval-config [args: record]: nothing -> record {
|
||||||
let eval_config_nix = $env.FILE_PWD + "/lib/eval-config.nix"
|
let eval_config_nix = (libexec-dir) + "/lib/eval-config.nix"
|
||||||
|
|
||||||
do { nix-eval-expr $"import ($eval_config_nix) \(builtins.fromJSON ''($args | to json -r)'')" }
|
do { nix-eval-expr $"import ($eval_config_nix) \(builtins.fromJSON ''($args | to json -r)'')" }
|
||||||
| complete
|
| complete
|
||||||
|
|
5
lib/libexec-dir.nu
Normal file
5
lib/libexec-dir.nu
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export def main []: nothing -> path {
|
||||||
|
# $env.FILE_PWD contains the file of the script (disko.nu), not this module
|
||||||
|
let libexec_dir = $env.FILE_PWD
|
||||||
|
$libexec_dir
|
||||||
|
}
|
38
package-disko2.nix
Normal file
38
package-disko2.nix
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
{ stdenvNoCC, makeWrapper, lib, path, nix, coreutils, nixos-install-tools, binlore, diskoVersion }:
|
||||||
|
|
||||||
|
let
|
||||||
|
shareDir = "share/disko2";
|
||||||
|
self = stdenvNoCC.mkDerivation (finalAttrs: {
|
||||||
|
name = "disko2";
|
||||||
|
src = ./.;
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin $out/${shareDir}
|
||||||
|
cp -r default.nix disk-deactivate lib $out/${shareDir}
|
||||||
|
cp disko2 $out/bin/
|
||||||
|
|
||||||
|
sed -ie "s|libexec_dir = .*|libexec_dir = '$out/${shareDir}'|" $out/${shareDir}/lib/libexec-dir.nu
|
||||||
|
sed -ie "s|use lib|use \"$out/${shareDir}/lib\"|" $out/bin/disko2
|
||||||
|
chmod 755 "$out/bin/disko2"
|
||||||
|
wrapProgram "$out/bin/disko2" \
|
||||||
|
--set DISKO_VERSION "${diskoVersion}" \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ nix coreutils nixos-install-tools ]} \
|
||||||
|
--prefix NIX_PATH : "nixpkgs=${path}"
|
||||||
|
'';
|
||||||
|
# Otherwise resholve thinks that disko and disko-install might be able to execute their arguments
|
||||||
|
passthru.binlore.out = binlore.synthesize self ''
|
||||||
|
execer cannot bin/.disko2-wrapped
|
||||||
|
'';
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Format disks with nix-config";
|
||||||
|
homepage = "https://github.com/nix-community/disko";
|
||||||
|
license = licenses.mit;
|
||||||
|
maintainers = with maintainers; [ lassulus ];
|
||||||
|
platforms = platforms.linux;
|
||||||
|
mainProgram = finalAttrs.name;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
in
|
||||||
|
self
|
Loading…
Reference in a new issue