From 63ffb56130a449f3743a74e5a3bf33310fdd1299 Mon Sep 17 00:00:00 2001 From: Stefano Debenedetti <44903077+demaledetti@users.noreply.github.com> Date: Tue, 27 May 2025 20:19:15 +0200 Subject: [PATCH 1/4] Add a new projectArgs CLI argument to pass arguments to the hix project in the flake generated by hix run --- hix/default.nix | 12 +++++++++++- hix/project/flake.nix | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hix/default.nix b/hix/default.nix index 289a57654e..136fd29b7e 100644 --- a/hix/default.nix +++ b/hix/default.nix @@ -31,9 +31,16 @@ let flake|build|develop|run|profile) # Put the flake files for remote URLs in $HOME/.hix by default HIX_DIR="''${HIX_DIR:-$HOME/.hix}" + HIX_TMPDIR="$(mktemp -d)" + projectArgs="" while(($#)); do arg=$1 case $arg in + --projectArgs) + projectArgs="$2" + args+=(--override-input projectArgs "$HIX_TMPDIR") + shift + ;; --out-link|-o|--eval-store|--include|-I|--inputs-from|--expr|--file|-f|--keep|-k|--phase|--profile|--unset|-u) args+=("$arg" "$2") shift @@ -83,7 +90,7 @@ let fi # Make a temporary flake if we have not already mkdir -p $FLAKE - HIX_FLAKE="$(mktemp -d)/flake.nix" + HIX_FLAKE="$HIX_TMPDIR/flake.nix" sed 's|EVAL_SYSTEM|${pkgs.stdenv.hostPlatform.system}|' < ${hixProject}/flake.nix > $HIX_FLAKE if ! cmp $HIX_FLAKE $FLAKE/flake.nix &>/dev/null; then if [ -e $FLAKE/flake.lock ]; then @@ -95,6 +102,9 @@ let cp $HIX_FLAKE $FLAKE/flake.nix chmod +w $FLAKE/flake.nix fi + if [ "$projectArgs" != "" ]; then + printf %s "$projectArgs" > "$HIX_TMPDIR/default.nix" + fi nix $cmd "''${args[@]}" ;; init|init-hix) diff --git a/hix/project/flake.nix b/hix/project/flake.nix index 5fbbed0aef..28f676d563 100644 --- a/hix/project/flake.nix +++ b/hix/project/flake.nix @@ -5,16 +5,18 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.projectArgs.url = "github:demaledetti/empty-set"; + inputs.projectArgs.flake = false; inputs.src.flake = false; - outputs = { self, src, nixpkgs, flake-utils, haskellNix }: + outputs = { self, src, nixpkgs, flake-utils, haskellNix, projectArgs }: flake-utils.lib.eachSystem [ "EVAL_SYSTEM" ] (system: let overlays = [ haskellNix.overlay (final: _prev: { hixProject = - final.haskell-nix.hix.project { + final.haskell-nix.hix.project ({ inherit src; - }; + } // import projectArgs ); }) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; From e12ddcc6348e48092d7382236c0092799ec47d2c Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 28 May 2025 16:56:23 +1200 Subject: [PATCH 2/4] Use `input-output-hk/empty-flake` --- hix/project/flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hix/project/flake.nix b/hix/project/flake.nix index 28f676d563..20774c6f7a 100644 --- a/hix/project/flake.nix +++ b/hix/project/flake.nix @@ -5,7 +5,7 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.projectArgs.url = "github:demaledetti/empty-set"; + inputs.projectArgs.url = "github:input-output-hk/empty-flake"; inputs.projectArgs.flake = false; inputs.src.flake = false; outputs = { self, src, nixpkgs, flake-utils, haskellNix, projectArgs }: @@ -16,7 +16,7 @@ hixProject = final.haskell-nix.hix.project ({ inherit src; - } // import projectArgs ); + } // builtins.removeAttrs (import projectArgs) ["outputs"] ); }) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; From 78eb370d14bbbd79b4b62a0bff6e2ef7995b375f Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 28 May 2025 21:41:04 +1200 Subject: [PATCH 3/4] Use #2379 --- hix/project/flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hix/project/flake.nix b/hix/project/flake.nix index 20774c6f7a..b3c6a1051f 100644 --- a/hix/project/flake.nix +++ b/hix/project/flake.nix @@ -5,7 +5,7 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.projectArgs.url = "github:input-output-hk/empty-flake"; + inputs.projectArgs.url = "github:input-output-hk/haskell.nix?dir=hix/empty-set"; inputs.projectArgs.flake = false; inputs.src.flake = false; outputs = { self, src, nixpkgs, flake-utils, haskellNix, projectArgs }: @@ -16,7 +16,7 @@ hixProject = final.haskell-nix.hix.project ({ inherit src; - } // builtins.removeAttrs (import projectArgs) ["outputs"] ); + } // import projectArgs); }) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; }; From 57d972e5d6b21242723c6eee85fa0c75d080efd1 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 28 May 2025 22:18:54 +1200 Subject: [PATCH 4/4] Look for `projectArgs.nix` --- hix/default.nix | 2 +- hix/empty-set/default.nix | 1 - hix/project/flake.nix | 7 +++++-- 3 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 hix/empty-set/default.nix diff --git a/hix/default.nix b/hix/default.nix index 136fd29b7e..8867daa976 100644 --- a/hix/default.nix +++ b/hix/default.nix @@ -103,7 +103,7 @@ let chmod +w $FLAKE/flake.nix fi if [ "$projectArgs" != "" ]; then - printf %s "$projectArgs" > "$HIX_TMPDIR/default.nix" + printf %s "$projectArgs" > "$HIX_TMPDIR/projectArgs.nix" fi nix $cmd "''${args[@]}" ;; diff --git a/hix/empty-set/default.nix b/hix/empty-set/default.nix deleted file mode 100644 index 0967ef424b..0000000000 --- a/hix/empty-set/default.nix +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/hix/project/flake.nix b/hix/project/flake.nix index b3c6a1051f..26641d1ed3 100644 --- a/hix/project/flake.nix +++ b/hix/project/flake.nix @@ -5,7 +5,7 @@ inputs.haskellNix.url = "github:input-output-hk/haskell.nix"; inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable"; inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.projectArgs.url = "github:input-output-hk/haskell.nix?dir=hix/empty-set"; + inputs.projectArgs.url = "github:input-output-hk/empty-flake"; inputs.projectArgs.flake = false; inputs.src.flake = false; outputs = { self, src, nixpkgs, flake-utils, haskellNix, projectArgs }: @@ -16,7 +16,10 @@ hixProject = final.haskell-nix.hix.project ({ inherit src; - } // import projectArgs); + } // ( + if builtins.pathExists (projectArgs + "/projectArgs.nix") + then import (projectArgs + "/projectArgs.nix") + else {})); }) ]; pkgs = import nixpkgs { inherit system overlays; inherit (haskellNix) config; };