diff options
Diffstat (limited to 'flake.nix')
| -rw-r--r-- | flake.nix | 272 |
1 files changed, 31 insertions, 241 deletions
@@ -7,18 +7,13 @@ }; outputs = - { - self, - nixpkgs, - nixpkgs-stable, - nix-darwin, - home-manager, - ... - }@inputs: + inputs: let - inherit (nixpkgs) lib; + flakeModules = import ./modules/flake; + in + inputs.flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" "aarch64-linux" @@ -26,243 +21,32 @@ "aarch64-darwin" ]; - forAllSystems = lib.genAttrs systems; - nixpkgsFor = nixpkgs.legacyPackages; - - mkModule = type: name: file: { - _file = "${self.outPath}#${type}.${name}"; - imports = [ file ]; - }; - in - - { - apps = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - - opentofu = pkgs.opentofu.withPlugins (plugins: [ - plugins.cloudflare - plugins.tailscale - ]); - - terranix = inputs.terranix.lib.terranixConfiguration { - inherit system; - modules = [ ./terranix ]; - }; - in - { - tf = { - type = "app"; - program = lib.getExe ( - pkgs.writeShellScriptBin "tf" '' - ln -sf ${terranix} config.tf.json - exec ${lib.getExe opentofu} "$@" - '' - ); - }; - } - ); - - checks = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - - mkCheck = - { - name, - deps ? [ ], - script, - }: - pkgs.runCommand name { nativeBuildInputs = deps; } '' - ${script} - touch $out - ''; - in - { - actionlint = mkCheck { - name = "check-actionlint"; - deps = [ pkgs.actionlint ]; - script = "actionlint ${self}/.github/workflows/**"; - }; - - deadnix = mkCheck { - name = "check-deadnix"; - deps = [ pkgs.deadnix ]; - script = "deadnix --fail ${self}"; - }; - - just = mkCheck { - name = "check-just"; - deps = [ pkgs.just ]; - script = '' - cd ${self} - just --check --fmt --unstable - just --summary - ''; - }; - - nixfmt = mkCheck { - name = "check-nixfmt"; - deps = [ pkgs.nixfmt-rfc-style ]; - script = "nixfmt --check ${self}/**/*.nix"; - }; - - statix = mkCheck { - name = "check-statix"; - deps = [ pkgs.statix ]; - script = "statix check ${self}"; - }; - } - ); - - devShells = forAllSystems ( - system: - let - pkgs = nixpkgsFor.${system}; - in - { - default = pkgs.mkShellNoCC { - packages = - [ - # We want to make sure we have the same - # Nix behavior across machines - pkgs.nix - - # For CI - pkgs.actionlint - - # Nix tools - pkgs.nil - pkgs.statix - self.formatter.${system} - - pkgs.just - ] - ++ lib.optionals pkgs.stdenv.hostPlatform.isDarwin [ - # See above comment about Nix - inputs.nix-darwin.packages.${system}.darwin-rebuild - ] - ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ - - # Ditto - pkgs.nixos-rebuild - - inputs.agenix.packages.${system}.agenix - ]; - }; - } - ); - - lib = import ./lib { inherit lib; }; - - formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style); - - darwinModules = lib.mapAttrs (mkModule "darwin") { - default = ./modules/darwin; - }; - - nixosModules = lib.mapAttrs (mkModule "darwin") { - default = ./modules/nixos; - }; - - darwinConfigurations = lib.mapAttrs (lib.const nix-darwin.lib.darwinSystem) { - caroline = { - modules = [ ./systems/caroline ]; - specialArgs = { - inherit inputs; - }; - }; - }; - - homeConfigurations = lib.mapAttrs (lib.const home-manager.lib.homeManagerConfiguration) { - seth = { - modules = [ ./users/seth/home.nix ]; - pkgs = nixpkgsFor.x86_64-linux; - extraSpecialArgs = { - inherit inputs; - }; - }; - }; - - nixosConfigurations = - lib.mapAttrs (lib.const nixpkgs.lib.nixosSystem) { - glados = { - modules = [ ./systems/glados ]; - specialArgs = { - inherit inputs; - }; - }; - - glados-wsl = { - modules = [ ./systems/glados-wsl ]; - specialArgs = { - inherit inputs; - }; - }; - } - // { - atlas = nixpkgs-stable.lib.nixosSystem { - modules = [ ./systems/atlas ]; - specialArgs = { - inherit inputs; - }; - }; - }; - - legacyPackages.x86_64-linux = - let - pkgs = nixpkgsFor.x86_64-linux; - - openwrtTools = lib.makeScope pkgs.newScope (final: { - profileFromRelease = - release: (inputs.openwrt-imagebuilder.lib.profiles { inherit pkgs release; }).identifyProfile; - - buildOpenWrtImage = - { profile, ... }@args: - inputs.openwrt-imagebuilder.lib.build ( - final.profileFromRelease args.release profile - // builtins.removeAttrs args [ - "profile" - "release" - ] - ); - }); - in - { - turret = openwrtTools.callPackage ./openwrt/turret.nix { }; - }; - - hydraJobs = - let - # Architecture of "main" CI machine - ciSystem = "x86_64-linux"; - - derivFromCfg = deriv: deriv.config.system.build.toplevel or deriv.activationPackage; - mapCfgsToDerivs = lib.mapAttrs (lib.const derivFromCfg); - - pkgs = nixpkgsFor.${ciSystem}; - in - { - # I don't care to run these for each system, as they should be the same - # and don't need to be cached - checks = self.checks.${ciSystem}; - devShells = self.devShells.${ciSystem}; + imports = [ + flakeModules.terranix + inputs.getchpkgs.flakeModules.configs + inputs.getchpkgs.flakeModules.checks + + ./flake + ./lib + ./modules + ./openwrt + ./systems + ./terranix + ./users + ]; - darwinConfigurations = mapCfgsToDerivs self.darwinConfigurations; - homeConfigurations = mapCfgsToDerivs self.homeConfigurations; - nixosConfigurations = mapCfgsToDerivs self.nixosConfigurations // { - # please add aarch64 runners github...please... - atlas = lib.deepSeq (derivFromCfg self.nixosConfigurations.atlas).drvPath pkgs.emptyFile; - }; - }; + flake = { inherit flakeModules; }; }; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.11"; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + nix-darwin = { url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; @@ -309,6 +93,11 @@ }; }; + getchpkgs = { + url = "github:getchoo/nix-exprs"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + getchvim = { url = "github:getchoo/getchvim"; inputs.nixpkgs.follows = "nixpkgs"; @@ -328,6 +117,7 @@ url = "github:nix-community/lanzaboote"; inputs = { nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; flake-compat.follows = ""; pre-commit-hooks-nix.follows = ""; }; @@ -364,7 +154,7 @@ url = "github:astro/nix-openwrt-imagebuilder"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-parts.follows = "lanzaboote/flake-parts"; + flake-parts.follows = "flake-parts"; systems.follows = "nixos-wsl/flake-utils/systems"; }; }; @@ -378,7 +168,7 @@ url = "github:terranix/terranix"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-parts.follows = "lanzaboote/flake-parts"; + flake-parts.follows = "flake-parts"; systems.follows = "nixos-wsl/flake-utils/systems"; terranix-examples.follows = ""; bats-support.follows = ""; |
