2023-08-26 22:18:17 +00:00
|
|
|
{ self, ... }: {
|
2023-09-02 14:12:37 +00:00
|
|
|
perSystem = { pkgs, lib, self', ... }:
|
2023-08-26 22:18:17 +00:00
|
|
|
let
|
2023-08-27 08:05:48 +00:00
|
|
|
impureChecks = {
|
2023-09-19 14:46:38 +00:00
|
|
|
clan-pytest-impure = pkgs.writeShellScriptBin "clan-pytest-impure" ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2023-09-21 15:17:48 +00:00
|
|
|
export PATH="${lib.makeBinPath [
|
2023-09-19 14:46:38 +00:00
|
|
|
pkgs.gitMinimal
|
|
|
|
pkgs.nix
|
2023-09-21 15:17:48 +00:00
|
|
|
]}"
|
|
|
|
ROOT=$(git rev-parse --show-toplevel)
|
|
|
|
cd "$ROOT/pkgs/clan-cli"
|
|
|
|
nix develop "$ROOT#clan-cli" -c bash -c 'TMPDIR=/tmp python -m pytest -m impure -s ./tests'
|
2023-09-19 14:46:38 +00:00
|
|
|
'';
|
2023-08-27 08:05:48 +00:00
|
|
|
check-clan-template = pkgs.writeShellScriptBin "check-clan-template" ''
|
2023-08-26 22:18:17 +00:00
|
|
|
#!${pkgs.bash}/bin/bash
|
2023-09-21 15:17:48 +00:00
|
|
|
set -euox pipefail
|
2023-09-02 16:28:31 +00:00
|
|
|
|
2023-09-21 15:17:48 +00:00
|
|
|
export CLANTMP=$(${pkgs.coreutils}/bin/mktemp -d)
|
|
|
|
trap "${pkgs.coreutils}/bin/chmod -R +w '$CLANTMP'; ${pkgs.coreutils}/bin/rm -rf '$CLANTMP'" EXIT
|
2023-09-02 16:28:31 +00:00
|
|
|
|
2023-08-26 22:18:17 +00:00
|
|
|
export PATH="${lib.makeBinPath [
|
2023-09-02 16:28:31 +00:00
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.curl
|
2023-08-27 08:05:48 +00:00
|
|
|
pkgs.gitMinimal
|
2023-09-02 14:12:37 +00:00
|
|
|
pkgs.gnugrep
|
|
|
|
pkgs.jq
|
2023-08-27 08:05:48 +00:00
|
|
|
pkgs.openssh
|
2023-08-26 22:18:17 +00:00
|
|
|
pkgs.nix
|
2023-09-03 13:17:28 +00:00
|
|
|
self'.packages.clan-cli
|
2023-08-26 22:18:17 +00:00
|
|
|
]}"
|
|
|
|
|
2023-09-21 15:17:48 +00:00
|
|
|
cd $CLANTMP
|
2023-08-26 22:18:17 +00:00
|
|
|
|
|
|
|
echo initialize new clan
|
|
|
|
nix flake init -t ${self}#new-clan
|
|
|
|
|
2023-09-02 14:12:37 +00:00
|
|
|
echo override clan input to the current version
|
|
|
|
nix flake lock --override-input clan-core ${self}
|
|
|
|
nix flake lock --override-input nixpkgs ${self.inputs.nixpkgs}
|
|
|
|
|
2023-08-26 22:18:17 +00:00
|
|
|
echo ensure flake outputs can be listed
|
|
|
|
nix flake show
|
2023-09-02 14:12:37 +00:00
|
|
|
|
|
|
|
echo create a machine
|
2023-09-03 13:17:28 +00:00
|
|
|
clan machines create machine1
|
2023-09-02 14:12:37 +00:00
|
|
|
|
|
|
|
echo check machine1 exists
|
2023-09-03 13:17:28 +00:00
|
|
|
clan machines list | grep -q machine1
|
2023-09-02 14:12:37 +00:00
|
|
|
|
|
|
|
echo check machine1 appears in nixosConfigurations
|
|
|
|
nix flake show --json | jq '.nixosConfigurations' | grep -q machine1
|
2023-09-02 16:28:31 +00:00
|
|
|
|
|
|
|
echo check machine1 jsonschema can be evaluated
|
|
|
|
nix eval .#nixosConfigurations.machine1.config.clanSchema
|
2023-08-26 22:18:17 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
packages =
|
2023-08-27 08:05:48 +00:00
|
|
|
impureChecks // {
|
2023-08-26 22:18:17 +00:00
|
|
|
# a script that executes all other checks
|
2023-08-27 08:05:48 +00:00
|
|
|
impure-checks = pkgs.writeShellScriptBin "impure-checks" ''
|
2023-08-26 22:18:17 +00:00
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
${lib.concatMapStringsSep "\n" (name: ''
|
|
|
|
echo -e "\n\nrunning check ${name}\n"
|
2023-09-19 14:46:38 +00:00
|
|
|
${impureChecks.${name}}/bin/* "$@"
|
2023-08-27 08:05:48 +00:00
|
|
|
'') (lib.attrNames impureChecks)}
|
2023-08-26 22:18:17 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|