diff --git a/flake.lock b/flake.lock index a57a1e6..479dfec 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,22 @@ { "nodes": { + "harmonia": { + "flake": false, + "locked": { + "lastModified": 1680542005, + "narHash": "sha256-fT9CJ/WAH5ESU4Ja062U/qNWDmhEfHI1XctnFjgBJ+A=", + "owner": "nix-community", + "repo": "harmonia", + "rev": "849a845c327ffb8fcc3322176479f6909f7a51a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "master", + "repo": "harmonia", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1681389457, @@ -16,6 +33,7 @@ }, "root": { "inputs": { + "harmonia": "harmonia", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 78bf446..2cb290e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,14 +1,29 @@ { description = "Kefla POC"; - outputs = { self, nixpkgs }: + inputs = { + harmonia = { + type = "github"; + owner = "nix-community"; + repo = "harmonia"; + ref = "master"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, ... }@inputs: let - kefla = import ./kefla nixpkgs; + kefla = import ./kefla inputs; in { packages = kefla { + # available on all achs package-all = ./package-all.nix; + # Darwin-only package-darwin = ./package-darwin.nix; + # Linux package-linux = ./package-linux.nix; + # Uses meta + package-flake-meta = ./package-flake-meta.nix; }; }; } diff --git a/kefla/internal.nix b/kefla/internal.nix index 75f162c..d26f618 100644 --- a/kefla/internal.nix +++ b/kefla/internal.nix @@ -1,10 +1,10 @@ -nixpkgs: +inputs: let - dummyPkgs = import nixpkgs { system = "x86_64-linux"; }; + dummyPkgs = import inputs.nixpkgs { system = "x86_64-linux"; }; lib = dummyPkgs.lib; in rec { - # Collects all the supported for drv leveraging the meta.platforms - # Nixpkgs attribute. + # Collects all the supported systems for drv leveraging the + # meta.platforms Nixpkgs attribute. # # We callPackage the derivation with a dummy Nixpkgs x86_64 # instance, regardless of the underlying arch. It doesn't matter @@ -37,16 +37,16 @@ in rec { let injectPlatformCallPackage = { attrs, platform }: let - pkgs = import nixpkgs { system = platform; }; - callPackage = pkgs.lib.callPackageWith pkgs; + pkgs = import inputs.nixpkgs { system = platform; }; + callPackage = pkgs.lib.callPackageWith (pkgs // { flakeMeta.inputs = inputs;} ); in builtins.mapAttrs (_name: value: callPackage value {}) attrs; in builtins.mapAttrs (name: value: injectPlatformCallPackage { attrs = value; platform = name; }) packages; - # - kefla = packagesOutput: let + # We first generate the packages output like in its final form. We + # just lack the callPackage on the derivation path. packagesWithoutCallPackage = lib.foldlAttrs (acc: name: path: let diff --git a/package-flake-meta.nix b/package-flake-meta.nix new file mode 100644 index 0000000..8b4159c --- /dev/null +++ b/package-flake-meta.nix @@ -0,0 +1,32 @@ +{ lib +, stdenv +, fetchurl +, flakeMeta +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "hello"; + version = "2.12.1"; + + src = fetchurl { + url = "mirror://gnu/hello/hello-${finalAttrs.version}.tar.gz"; + sha256 = "sha256-jZkUKv2SV28wsM18tCqNxoCZmLxdYH2Idh9RLibH2yA="; + }; + + doCheck = true; + + nativeBuildInputs = [ flakeMeta.inputs.harmonia ]; + + meta = with lib; { + description = "A program that produces a familiar, friendly greeting"; + longDescription = '' + GNU Hello is a program that prints "Hello, world!" when you run it. + It is fully customizable. + ''; + homepage = "https://www.gnu.org/software/hello/manual/"; + changelog = "https://git.savannah.gnu.org/cgit/hello.git/plain/NEWS?h=v${finalAttrs.version}"; + license = licenses.gpl3Plus; + maintainers = [ maintainers.eelco ]; + platforms = platforms.all; + }; +})