2021-06-29 10:02:43 +02:00
|
|
|
{
|
|
|
|
description = "A simple, stateless NixOS deployment tool modeled after NixOps.";
|
|
|
|
|
|
|
|
inputs = {
|
2022-01-28 03:48:25 +01:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2024-09-01 19:06:00 +02:00
|
|
|
stable.url = "github:NixOS/nixpkgs/nixos-24.05";
|
2022-01-28 03:48:25 +01:00
|
|
|
|
2024-11-07 23:24:37 +01:00
|
|
|
nix-github-actions = {
|
|
|
|
url = "github:nix-community/nix-github-actions";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2022-10-09 04:31:21 +02:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2021-06-29 10:02:43 +02:00
|
|
|
|
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-07 23:24:37 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
stable,
|
|
|
|
flake-utils,
|
|
|
|
nix-github-actions,
|
|
|
|
...
|
|
|
|
} @ inputs: let
|
2022-01-02 01:41:35 +01:00
|
|
|
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
2022-04-04 02:07:14 +02:00
|
|
|
colmenaOptions = import ./src/nix/hive/options.nix;
|
|
|
|
colmenaModules = import ./src/nix/hive/modules.nix;
|
2024-11-07 23:24:37 +01:00
|
|
|
|
|
|
|
# Temporary fork of nix-eval-jobs with changes to be upstreamed
|
|
|
|
# Mostly for the integration test setup and not needed in most use cases
|
|
|
|
_evalJobsOverlay = final: prev: let
|
|
|
|
patched = prev.nix-eval-jobs.overrideAttrs (old: {
|
|
|
|
version = old.version + "-colmena";
|
|
|
|
patches = (old.patches or []) ++ [
|
|
|
|
# Allows NIX_PATH to be honored
|
|
|
|
(final.fetchpatch {
|
|
|
|
url = "https://github.com/zhaofengli/nix-eval-jobs/commit/6ff5972724230ac2b96eb1ec355cd25ca512ef57.patch";
|
|
|
|
hash = "sha256-2NiMYpw27N+X7Ixh2HkP3fcWvopDJWQDVjgRdhOL2QQ";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
|
|
|
in {
|
|
|
|
nix-eval-jobs = patched;
|
|
|
|
};
|
2022-10-09 04:31:21 +02:00
|
|
|
in flake-utils.lib.eachSystem supportedSystems (system: let
|
2024-11-07 23:24:37 +01:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
_evalJobsOverlay
|
|
|
|
];
|
|
|
|
};
|
2021-06-29 10:02:43 +02:00
|
|
|
in rec {
|
|
|
|
# We still maintain the expression in a Nixpkgs-acceptable form
|
2021-09-20 07:03:39 +02:00
|
|
|
defaultPackage = self.packages.${system}.colmena;
|
2021-11-18 07:21:00 +01:00
|
|
|
packages = rec {
|
2022-01-21 09:45:12 +01:00
|
|
|
colmena = pkgs.callPackage ./package.nix { };
|
2021-11-18 07:21:00 +01:00
|
|
|
|
2021-11-18 22:15:20 +01:00
|
|
|
# Full user manual
|
2021-11-18 07:21:00 +01:00
|
|
|
manual = let
|
2022-07-09 22:41:15 +02:00
|
|
|
suppressModuleArgsDocs = { lib, ... }: {
|
|
|
|
options = {
|
|
|
|
_module.args = lib.mkOption {
|
|
|
|
internal = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-11-18 07:21:00 +01:00
|
|
|
colmena = self.packages.${system}.colmena;
|
|
|
|
deploymentOptionsMd = (pkgs.nixosOptionsDoc {
|
2022-07-09 22:41:15 +02:00
|
|
|
inherit (pkgs.lib.evalModules {
|
|
|
|
modules = [ colmenaOptions.deploymentOptions suppressModuleArgsDocs];
|
|
|
|
specialArgs = { name = "nixos"; nodes = {}; };
|
|
|
|
}) options;
|
2022-01-02 01:41:35 +01:00
|
|
|
}).optionsCommonMark;
|
2021-11-18 07:21:00 +01:00
|
|
|
metaOptionsMd = (pkgs.nixosOptionsDoc {
|
2022-07-09 22:41:15 +02:00
|
|
|
inherit (pkgs.lib.evalModules {
|
|
|
|
modules = [ colmenaOptions.metaOptions suppressModuleArgsDocs];
|
|
|
|
}) options;
|
2022-01-02 01:41:35 +01:00
|
|
|
}).optionsCommonMark;
|
2021-11-18 07:21:00 +01:00
|
|
|
in pkgs.callPackage ./manual {
|
|
|
|
inherit colmena deploymentOptionsMd metaOptionsMd;
|
|
|
|
};
|
|
|
|
|
2021-11-18 22:15:20 +01:00
|
|
|
# User manual without the CLI reference
|
2021-11-18 07:21:00 +01:00
|
|
|
manualFast = manual.override { colmena = null; };
|
2021-11-18 22:15:20 +01:00
|
|
|
|
|
|
|
# User manual with the version treated as stable
|
|
|
|
manualForceStable = manual.override { unstable = false; };
|
2021-11-18 07:21:00 +01:00
|
|
|
};
|
2021-06-29 10:02:43 +02:00
|
|
|
|
|
|
|
defaultApp = self.apps.${system}.colmena;
|
2022-06-03 01:39:45 +02:00
|
|
|
apps.default = self.apps.${system}.colmena;
|
2021-06-29 10:02:43 +02:00
|
|
|
apps.colmena = {
|
|
|
|
type = "app";
|
|
|
|
program = "${defaultPackage}/bin/colmena";
|
|
|
|
};
|
|
|
|
|
|
|
|
devShell = pkgs.mkShell {
|
2022-05-26 02:19:03 +02:00
|
|
|
RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library";
|
|
|
|
NIX_PATH = "nixpkgs=${pkgs.path}";
|
|
|
|
|
2022-03-08 07:02:04 +01:00
|
|
|
inputsFrom = [ defaultPackage packages.manualFast ];
|
|
|
|
packages = with pkgs; [
|
2022-06-03 01:39:45 +02:00
|
|
|
bashInteractive
|
2022-06-25 02:34:37 +02:00
|
|
|
editorconfig-checker
|
2022-08-17 04:15:43 +02:00
|
|
|
clippy rust-analyzer cargo-outdated cargo-audit rustfmt
|
2022-06-25 02:34:37 +02:00
|
|
|
python3 python3Packages.flake8
|
2022-03-08 07:02:04 +01:00
|
|
|
];
|
2021-06-29 10:02:43 +02:00
|
|
|
};
|
2023-01-28 07:44:41 +01:00
|
|
|
checks = let
|
|
|
|
inputsOverlay = final: prev: {
|
|
|
|
_inputs = inputs;
|
|
|
|
};
|
|
|
|
in if pkgs.stdenv.isLinux then import ./integration-tests {
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2024-10-06 03:46:56 +02:00
|
|
|
overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
inputsOverlay
|
|
|
|
|
2024-11-07 23:24:37 +01:00
|
|
|
_evalJobsOverlay
|
2024-10-06 03:46:56 +02:00
|
|
|
];
|
2023-01-28 07:44:41 +01:00
|
|
|
};
|
|
|
|
pkgsStable = import stable {
|
|
|
|
inherit system;
|
2024-10-06 03:46:56 +02:00
|
|
|
overlays = [
|
|
|
|
self.overlays.default
|
|
|
|
inputsOverlay
|
|
|
|
|
2024-11-07 23:24:37 +01:00
|
|
|
_evalJobsOverlay
|
2024-10-06 03:46:56 +02:00
|
|
|
];
|
2023-01-28 07:44:41 +01:00
|
|
|
};
|
|
|
|
} else {};
|
2021-09-20 07:03:39 +02:00
|
|
|
}) // {
|
2023-01-28 07:44:41 +01:00
|
|
|
overlay = self.overlays.default;
|
|
|
|
overlays.default = final: prev: {
|
2022-01-21 09:45:12 +01:00
|
|
|
colmena = final.callPackage ./package.nix { };
|
2021-09-20 07:03:39 +02:00
|
|
|
};
|
2022-05-27 00:23:39 +02:00
|
|
|
nixosModules = {
|
2022-09-19 01:27:46 +02:00
|
|
|
inherit (colmenaOptions) deploymentOptions metaOptions;
|
2022-10-23 04:34:48 +02:00
|
|
|
inherit (colmenaModules) keyChownModule keyServiceModule assertionModule;
|
2022-05-27 00:23:39 +02:00
|
|
|
};
|
2022-09-19 01:27:46 +02:00
|
|
|
|
|
|
|
lib.makeHive = rawHive: import ./src/nix/hive/eval.nix {
|
|
|
|
inherit rawHive colmenaOptions colmenaModules;
|
|
|
|
hermetic = true;
|
|
|
|
};
|
2024-11-07 23:24:37 +01:00
|
|
|
|
|
|
|
githubActions = nix-github-actions.lib.mkGithubMatrix {
|
|
|
|
checks = {
|
|
|
|
inherit (self.checks) x86_64-linux;
|
|
|
|
};
|
|
|
|
};
|
2021-09-20 07:03:39 +02:00
|
|
|
};
|
2022-05-26 01:55:39 +02:00
|
|
|
|
|
|
|
nixConfig = {
|
|
|
|
extra-substituters = [
|
|
|
|
"https://colmena.cachix.org"
|
|
|
|
];
|
|
|
|
extra-trusted-public-keys = [
|
|
|
|
"colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg="
|
|
|
|
];
|
|
|
|
};
|
2021-06-29 10:02:43 +02:00
|
|
|
}
|