Set up cachix

This commit is contained in:
Alex David 2026-01-28 10:53:41 -08:00
commit 7a05b0f6cf
2 changed files with 56 additions and 39 deletions

View file

@ -1,10 +1,21 @@
image: nixos/25.05 image: nixos/25.05
environment: environment:
NIX_CONFIG: "experimental-features = nix-command flakes" NIX_CONFIG: "experimental-features = nix-command flakes"
secrets:
- a0a725d2-f640-4a64-b71c-021d2f3f8378
sources: sources:
- https://git.sr.ht/~alexdavid/jail.nix - https://git.sr.ht/~alexdavid/jail.nix
tasks: tasks:
- setup: "sudo ln -s /etc/zoneinfo/EST /etc/localtime" - setup: |
- test-jail-nix: "cd jail.nix && nix run ./tests#runTests" sudo ln -s /etc/zoneinfo/EST /etc/localtime
- check-format: "cd jail.nix && nix run ./tests#checkFmt" nix-env -iA cachix -f https://cachix.org/api/v1/install
- build-website: "cd jail.nix && nix build -L ./website#default" cachix use jailnix
cachix doctor
- build-pkgs: |
cd jail.nix
nix build --print-build-logs --out-link result-tests ./tests#all-for-ci
cachix push jailnix result-tests
nix build --print-build-logs --out-link result-website ./website#default
cachix push jailnix result-website
- run-tests: cd jail.nix && cachix watch-exec jailnix -- result-tests/run-tests/bin/run-tests
- check-fmt: cd jail.nix && result-tests/check-fmt/bin/check-fmt

View file

@ -13,45 +13,51 @@
(haskellPackages.ghc.withPackages (p: cabal2nix.buildInputs)) (haskellPackages.ghc.withPackages (p: cabal2nix.buildInputs))
pkgs.cabal-install pkgs.cabal-install
]; ];
mkApp = name: runtimeInputs: script: { mkTestPackage =
type = "app"; name: runtimeInputs: script:
program = lib.getExe ( pkgs.writeShellApplication {
pkgs.writeShellApplication { inherit name runtimeInputs;
inherit name runtimeInputs; text = ''
text = '' if ! [ -e jail-nix-tests.cabal ]; then
if ! [ -e jail-nix-tests.cabal ]; then if [ -e tests/jail-nix-tests.cabal ]; then
if [ -e tests/jail-nix-tests.cabal ]; then cd tests
cd tests else
else echo "${name} must be called in repo root or tests directory"
echo "${name} must be called in repo root or tests directory" exit 1
exit 1
fi
fi fi
${script} fi
''; ${script}
} '';
); };
};
in in
{ rec {
apps.x86_64-linux.runTests = mkApp "run-all-jail-nix-tests" testDependencies '' packages.x86_64-linux = rec {
${ all-for-ci = pkgs.linkFarmFromDrvs "all-for-ci" [
lib.pipe run-tests
{ check-fmt
jail-nix = ../.; fmt
nixpkgs = nixpkgs; devShells.x86_64-linux.default
} ];
[
(lib.mapAttrsToList (name: path: "${name}=${path}"))
(lib.concatStringsSep " ")
(lib.toShellVar "NIX_PATH")
]
} cabal run spec -- "$@"
'';
apps.x86_64-linux.checkFmt = mkApp "check-fmt" [ pkgs.nixfmt-tree ] "treefmt --ci"; run-tests = mkTestPackage "run-tests" testDependencies ''
${
lib.pipe
{
jail-nix = ../.;
nixpkgs = nixpkgs;
}
[
(lib.mapAttrsToList (name: path: "${name}=${path}"))
(lib.concatStringsSep " ")
(lib.toShellVar "NIX_PATH")
]
} cabal run spec -- "$@"
'';
apps.x86_64-linux.fmt = mkApp "fmt" [ pkgs.nixfmt-tree ] "treefmt"; check-fmt = mkTestPackage "check-fmt" [ pkgs.nixfmt-tree ] "treefmt --ci";
fmt = mkTestPackage "fmt" [ pkgs.nixfmt-tree ] "treefmt";
};
devShells.x86_64-linux.default = pkgs.mkShell { devShells.x86_64-linux.default = pkgs.mkShell {
buildInputs = testDependencies ++ [ buildInputs = testDependencies ++ [