summaryrefslogtreecommitdiffstats
path: root/package.nix
blob: a8fc8be73f3ad35425fc32532933fcb9ca123862 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ coreutils, gnused, lib }:

let
  inclFiles = {src, name}: files: lib.cleanSourceWith {
    inherit src name;
    filter = _path: _type: _type == "regular" && lib.any (file: builtins.baseNameOf _path == file) files;
  };
in
derivation rec {
  system = "x86_64-linux";
  name = "disko";
  builder = "/bin/sh";
  PATH    = "${coreutils}/bin:${gnused}/bin";
  passAsFile = ["buildPhase"];
  buildPhase = ''
    mkdir -p $out/bin $out/share/disko
    cp -r $src/* $out/share/disko
    sed \
      -e "s|libexec_dir=\".*\"|libexec_dir=\"$out/share/disko\"|" \
      -e "s|#!/usr/bin/env.*|#!/usr/bin/env bash|" \
      $src/disko > $out/bin/disko
    chmod 755 $out/bin/disko
  '';
  args = ["-c" ". $buildPhasePath"];
  src = inclFiles { inherit name; src = ./.; } [
    "disko"
    "cli.nix"
    "default.nix"
    "types.nix"
    "options.nix"
  ];
} // {
  meta.description = "Format disks with nix-config";
}