summaryrefslogtreecommitdiff
path: root/flake
diff options
context:
space:
mode:
authorseth <[email protected]>2023-05-03 21:11:47 -0400
committerseth <[email protected]>2023-05-03 21:11:47 -0400
commitcf5647129499df68ac092b55b71a3cddc3422d01 (patch)
treef7685c8540cbab2bc51f87a2e9cda214d7d2dfae /flake
parentcdfc4ba1b2ef2b187e076a6f627e4631b6bd7fb3 (diff)
refactor flake + make virtualisation compatible with 22.11
Diffstat (limited to 'flake')
-rw-r--r--flake/ci.nix52
-rw-r--r--flake/configs.nix28
-rw-r--r--flake/default.nix14
-rw-r--r--flake/dev.nix47
4 files changed, 141 insertions, 0 deletions
diff --git a/flake/ci.nix b/flake/ci.nix
new file mode 100644
index 0000000..3959260
--- /dev/null
+++ b/flake/ci.nix
@@ -0,0 +1,52 @@
+{
+ inputs,
+ self,
+ ...
+}: let
+ inherit (inputs) hercules-ci-effects nixpkgs;
+in {
+ imports = [
+ hercules-ci-effects.flakeModule
+ ];
+
+ hercules-ci = {
+ flake-update = {
+ enable = true;
+ when = {
+ hour = [0];
+ minute = 0;
+ };
+ };
+ };
+
+ herculesCI = let
+ inherit (import (hercules-ci-effects + "/vendor/hercules-ci-agent/default-herculesCI-for-flake.nix")) flakeToOutputs;
+ in rec {
+ ciSystems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ ];
+
+ onPush = {
+ default = {
+ outputs = with builtins;
+ with nixpkgs.lib; let
+ # use defaults, but only evaluate hosts
+ defaults =
+ removeAttrs
+ (flakeToOutputs self {
+ ciSystems = genAttrs ciSystems (_: {});
+ })
+ ["nixosConfigurations" "packages"];
+
+ evaluate = mapAttrs (_: v:
+ seq
+ v.config.system.build.toplevel
+ v._module.args.pkgs.emptyFile)
+ self.nixosConfigurations;
+ in
+ mkForce (defaults // evaluate);
+ };
+ };
+ };
+}
diff --git a/flake/configs.nix b/flake/configs.nix
new file mode 100644
index 0000000..9660616
--- /dev/null
+++ b/flake/configs.nix
@@ -0,0 +1,28 @@
+{
+ inputs,
+ self,
+ ...
+}: let
+ inherit (inputs) nixinate openwrt-imagebuilder;
+ inherit ((inputs.getchoo.lib inputs).configs) mapHMUsers mapHosts;
+in {
+ flake = {
+ nixosConfigurations = mapHosts ../hosts;
+
+ nixosModules.getchoo = import ../modules;
+ };
+
+ perSystem = {
+ pkgs,
+ system,
+ ...
+ }: {
+ apps = (nixinate.nixinate.${system} self).nixinate;
+
+ legacyPackages.homeConfigurations = mapHMUsers system ../users;
+
+ packages = {
+ turret = pkgs.callPackage ../hosts/_turret {inherit openwrt-imagebuilder;};
+ };
+ };
+}
diff --git a/flake/default.nix b/flake/default.nix
new file mode 100644
index 0000000..a479898
--- /dev/null
+++ b/flake/default.nix
@@ -0,0 +1,14 @@
+_: {
+ imports = [
+ ./configs.nix
+ ./ci.nix
+ ./dev.nix
+ ];
+
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+}
diff --git a/flake/dev.nix b/flake/dev.nix
new file mode 100644
index 0000000..700c795
--- /dev/null
+++ b/flake/dev.nix
@@ -0,0 +1,47 @@
+{
+ self,
+ inputs,
+ ...
+}: let
+ inherit (inputs) pre-commit-hooks ragenix;
+in {
+ perSystem = {
+ pkgs,
+ system,
+ ...
+ }: {
+ checks = {
+ pre-commit-check = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ actionlint.enable = true;
+ alejandra.enable = true;
+ deadnix.enable = true;
+ statix.enable = true;
+ stylua.enable = true;
+ };
+ };
+ };
+
+ devShells = let
+ inherit (pkgs) mkShell;
+ in {
+ default = mkShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ packages = with pkgs; [
+ actionlint
+ ragenix.packages.${system}.ragenix
+ alejandra
+ deadnix
+ fzf
+ git-crypt
+ just
+ statix
+ stylua
+ ];
+ };
+ };
+
+ formatter = pkgs.alejandra;
+ };
+}