Skip to content

Commit

Permalink
use cachix wrapper for all bootstrap nix commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tek committed Sep 24, 2023
1 parent 2b9cbf6 commit 621ddf7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description = "Haskell/Nix development build tools";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/7e63eed145566cca98158613f3700515b4009ce3";
nixpkgs.url = "github:nixos/nixpkgs/e12483116b3b51a185a33a272bf351e357ba9a99";
thax.url = "github:tek/thax";
};

Expand Down
11 changes: 6 additions & 5 deletions lib/with-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ let
chmod +x $exe
'';

nixC = "${config.pkgs.nix}/bin/nix --option extra-substituters 'https://tek.cachix.org' --option extra-trusted-public-keys 'tek.cachix.org-1:+sdc73WFq8aEKnrVv5j/kuhmnW2hQJuqdPJF5SnaCBk='";

bootstrapWithStaticCli = name: pre: post: pkgs.writeScript name ''
#!${pkgs.bashInteractive}/bin/bash
set -e
Expand All @@ -104,7 +106,7 @@ let
${pkgs.git}/bin/git init
fi
${pkgs.git}/bin/git add .
${pkgs.nix}/bin/nix flake update
${nixC} flake update
${pkgs.git}/bin/git add flake.lock
${post}
'';
Expand All @@ -119,15 +121,13 @@ let
${pkgs.git}/bin/git init
fi
${pkgs.git}/bin/git add .
${pkgs.nix}/bin/nix flake update
${nixC} flake update
${pkgs.git}/bin/git add flake.lock
${post}
'';

cacheWrapper = self: name: app: pkgs.writeScript name ''
${config.pkgs.nix}/bin/nix --option extra-substituters 'https://tek.cachix.org' \
--option extra-trusted-public-keys 'tek.cachix.org-1:+sdc73WFq8aEKnrVv5j/kuhmnW2hQJuqdPJF5SnaCBk=' \
run ${self}#${app} -- "$@"
${nixC} run ${self}#${app} -- "$@"
'';

envSystemAllowed = env:
Expand All @@ -154,5 +154,6 @@ in basic // {
cacheWrapper
envSystemAllowed
hsLib
nixC
;
}
15 changes: 8 additions & 7 deletions local.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{inputs, hix}:

hix.pro [({config, lib, ...}: {
hix.pro [({config, lib, ...}: let
pkgs = config.pkgs;
in {
compiler = "ghc94";

hackage = {
Expand Down Expand Up @@ -86,8 +88,7 @@ hix.pro [({config, lib, ...}: {
outputs = {

packages = let
pkgs = import inputs.nixpkgs { inherit (config) system; };
docs = import ./lib/doc/default.nix { inherit inputs pkgs; inherit (config.internal) hixUrl; };
docs = import ./lib/doc/default.nix { inherit inputs; inherit (config) pkgs; inherit (config.internal) hixUrl; };
in {
docs = docs.html;
};
Expand All @@ -111,15 +112,15 @@ hix.pro [({config, lib, ...}: {
prog = util.bootstrapWithDynamicCli "hix-new-nocache" ''
$exe new --hix-url '${config.internal.hixUrl}' "$@"
'' ''
nix run .#gen-cabal
${util.nixC} run .#gen-cabal
'';
in {
type = "app";
program = "${prog}";
};

new = let
prog = util.cacheWrapper inputs.self "hix-new" "new-nocache";
prog = pkgs.writeScript "hix-new" ''${util.nixC} run ${inputs.self}#new-nocache -- "$@"'';
in {
type = "app";
program = "${prog}";
Expand All @@ -129,15 +130,15 @@ hix.pro [({config, lib, ...}: {
prog = util.bootstrapWithDynamicCli "hix-bootstrap-nocache" ''
$exe bootstrap --hix-url '${config.internal.hixUrl}' "$@"
'' ''
nix run .#gen-cabal
${util.nixC} run .#gen-cabal
'';
in {
type = "app";
program = "${prog}";
};

bootstrap = let
prog = util.cacheWrapper inputs.self "hix-bootstrap" "bootstrap-nocache";
prog = pkgs.writeScript "hix-bootstrap" ''${util.nixC} run ${inputs.self}#bootstrap-nocache -- "$@"'';
in {
type = "app";
program = "${prog}";
Expand Down
5 changes: 2 additions & 3 deletions test/cross/root/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

inputs.hix.url = "path:HIX";

outputs = { hix, ... }:
hix.lib.flake ({ config, ... }: {
outputs = {hix, ...}:
hix.lib.flake ({config, ...}: {
packages.root = {
src = ./.;
library.enable = true;
executable.enable = true;
};
compiler = "ghc94";
envs.dev.ghc.crossPkgs = config.envs.dev.ghc.pkgs.pkgsCross.musl64;
overrides = { hsLib, self, ... }: {
static = hsLib.justStaticExecutables self.root;
Expand Down

0 comments on commit 621ddf7

Please sign in to comment.