From 9e2c9d06f53b811f35fecfc2e924136ff4d379b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 9 Dec 2022 14:22:45 +0100 Subject: expose disko for non x86 --- flake.nix | 59 +++++++++++++++++++---------------------------------------- package.nix | 34 ++++++++++++++++++++++++++++++++++ tests/lib.nix | 2 +- 3 files changed, 54 insertions(+), 41 deletions(-) create mode 100644 package.nix diff --git a/flake.nix b/flake.nix index c2039b7..0344eb0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,57 +1,36 @@ { - description = "Description for the project"; + description = "Disko - declarative disk partitioning"; # don't lock to give precedence to a USB live-installer's registry inputs.nixpkgs.url = "nixpkgs"; - outputs = { self, nixpkgs, ... }: { + outputs = { self, nixpkgs, ... }: let + supportedSystems = [ + "x86_64-linux" + "i686-linux" + "aarch64-linux" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + in { nixosModules.disko = import ./module.nix; lib = import ./. { inherit (nixpkgs) lib; }; - packages.x86_64-linux.disko = let - pkgs = nixpkgs.legacyPackages.x86_64-linux; - inherit (pkgs) lib; - 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 = "${pkgs.coreutils}/bin:${pkgs.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"; - }; - packages.x86_64-linux.default = self.packages.x86_64-linux.disko; - checks.x86_64-linux = let - pkgs = nixpkgs.legacyPackages.x86_64-linux; + packages = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + disko = pkgs.callPackage ./package.nix {}; + default = self.packages.${system}.disko; + }); + # TODO: disable bios-related tests on aarch64... + checks = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; in # Run tests: nix flake check -L import ./tests { inherit pkgs; makeTest = import (pkgs.path + "/nixos/tests/make-test-python.nix"); eval-config = import (pkgs.path + "/nixos/lib/eval-config.nix"); - }; + }); }; } diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..a8fc8be --- /dev/null +++ b/package.nix @@ -0,0 +1,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"; +} diff --git a/tests/lib.nix b/tests/lib.nix index 95f267e..4b81da7 100644 --- a/tests/lib.nix +++ b/tests/lib.nix @@ -66,7 +66,7 @@ }; installedTopLevel = (eval-config { modules = [ installed-system ]; - system = "x86_64-linux"; + inherit (pkgs) system; }).config.system.build.toplevel; in makeTest' { -- cgit v1.2.3 From 17d17217d81c66d9e3fe5cd72155088c99f35155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 9 Dec 2022 14:27:30 +0100 Subject: use stdenvNoCC instead of barebone derivation --- package.nix | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/package.nix b/package.nix index a8fc8be..6e63310 100644 --- a/package.nix +++ b/package.nix @@ -1,4 +1,4 @@ -{ coreutils, gnused, lib }: +{ stdenvNoCC, lib }: let inclFiles = {src, name}: files: lib.cleanSourceWith { @@ -6,13 +6,16 @@ let filter = _path: _type: _type == "regular" && lib.any (file: builtins.baseNameOf _path == file) files; }; in -derivation rec { - system = "x86_64-linux"; +stdenvNoCC.mkDerivation rec { name = "disko"; - builder = "/bin/sh"; - PATH = "${coreutils}/bin:${gnused}/bin"; - passAsFile = ["buildPhase"]; - buildPhase = '' + src = inclFiles { inherit name; src = ./.; } [ + "disko" + "cli.nix" + "default.nix" + "types.nix" + "options.nix" + ]; + installPhase = '' mkdir -p $out/bin $out/share/disko cp -r $src/* $out/share/disko sed \ @@ -21,14 +24,11 @@ derivation rec { $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"; + 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; + }; } -- cgit v1.2.3