colmena/flake.nix

122 lines
3.8 KiB
Nix
Raw Normal View History

{
description = "A simple, stateless NixOS deployment tool modeled after NixOps.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
stable.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-utils.url = "github:numtide/flake-utils";
nix-eval-jobs = {
# Temporary fork of nix-eval-job with changes to be upstreamed
url = "github:zhaofengli/nix-eval-jobs/colmena";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
};
outputs = { self, nixpkgs, flake-utils, nix-eval-jobs, ... }: let
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
colmenaOptions = import ./src/nix/hive/options.nix;
colmenaModules = import ./src/nix/hive/modules.nix;
in flake-utils.lib.eachSystem supportedSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [ self._evalJobsOverlay ];
};
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;
packages = rec {
colmena = pkgs.callPackage ./package.nix { };
2021-11-18 22:15:20 +01:00
# Full user manual
manual = let
suppressModuleArgsDocs = { lib, ... }: {
options = {
_module.args = lib.mkOption {
internal = true;
};
};
};
colmena = self.packages.${system}.colmena;
deploymentOptionsMd = (pkgs.nixosOptionsDoc {
inherit (pkgs.lib.evalModules {
modules = [ colmenaOptions.deploymentOptions suppressModuleArgsDocs];
specialArgs = { name = "nixos"; nodes = {}; };
}) options;
2022-01-02 01:41:35 +01:00
}).optionsCommonMark;
metaOptionsMd = (pkgs.nixosOptionsDoc {
inherit (pkgs.lib.evalModules {
modules = [ colmenaOptions.metaOptions suppressModuleArgsDocs];
}) options;
2022-01-02 01:41:35 +01:00
}).optionsCommonMark;
in pkgs.callPackage ./manual {
inherit colmena deploymentOptionsMd metaOptionsMd;
};
2021-11-18 22:15:20 +01:00
# User manual without the CLI reference
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; };
};
defaultApp = self.apps.${system}.colmena;
2022-06-03 01:39:45 +02:00
apps.default = self.apps.${system}.colmena;
apps.colmena = {
type = "app";
program = "${defaultPackage}/bin/colmena";
};
devShell = pkgs.mkShell {
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; [
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-09-20 07:03:39 +02:00
}) // {
# Temporary fork of nix-eval-job with changes to be upstreamed
_evalJobsOverlay = final: prev: let
patched = nix-eval-jobs.packages.${final.system}.nix-eval-jobs.overrideAttrs (old: {
version = "2.9.0-colmena";
});
in {
nix-eval-jobs = patched;
};
2021-09-20 07:03:39 +02:00
overlay = final: prev: {
colmena = final.callPackage ./package.nix { };
2021-09-20 07:03: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;
};
lib.makeHive = rawHive: import ./src/nix/hive/eval.nix {
inherit rawHive colmenaOptions colmenaModules;
hermetic = true;
};
2021-09-20 07:03:39 +02:00
};
nixConfig = {
extra-substituters = [
"https://colmena.cachix.org"
];
extra-trusted-public-keys = [
"colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg="
];
};
}