From f9a2e83e7443687f81c80b15f6d1edc467e1ea9e Mon Sep 17 00:00:00 2001 From: ooks-io Date: Sun, 16 Jun 2024 15:40:41 +1200 Subject: [PATCH] feat(flake): move to withSystem & implement defaults system input --- flake.nix | 21 ++++---- hosts/ooksdesk/default.nix | 8 +-- outputs/nixos.nix | 100 +++++++++++++++++++------------------ outputs/shell.nix | 7 --- 4 files changed, 64 insertions(+), 72 deletions(-) delete mode 100644 outputs/shell.nix diff --git a/flake.nix b/flake.nix index 4af6f44..0be28da 100644 --- a/flake.nix +++ b/flake.nix @@ -3,23 +3,20 @@ description = "a nix configuration written by an orangutan"; outputs = { flake-parts, nixpkgs, self, ... } @ inputs: - flake-parts.lib.mkFlake { inherit inputs; } { + flake-parts.lib.mkFlake { inherit inputs; } ({withSystem, ... }: { - systems = [ - "x86_64-linux" - "aarch64-linux" - ]; + systems = import inputs.systems; imports = [ ./outputs/pkgs - ./outputs/nixos.nix + ./outputs/sshKeys.nix ]; - # flake = { - # nixosConfigurations = import ./flake/nixos.nix {inherit self inputs nixpkgs;}; - # }; + flake = { + nixosConfigurations = import ./outputs/nixos.nix {inherit self inputs withSystem;}; + }; - }; + }); # External inputs we depend on inputs = { @@ -34,6 +31,8 @@ # contains more up-to-date wayland related packages. no need enabling atm # nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland"; + # default system see + systems.url = "github:nix-systems/default-linux"; # split your flake into... parts? flake-parts = { url = "github:hercules-ci/flake-parts"; @@ -73,6 +72,8 @@ # colorschemes library nix-colors.url = "github:misterio77/nix-colors"; + # secret management + agenix.url = "github:ryantm/agenix"; # hyprland "ecosystem". hyprDE perhaps? # hyprland = { diff --git a/hosts/ooksdesk/default.nix b/hosts/ooksdesk/default.nix index 7e3350f..196310d 100644 --- a/hosts/ooksdesk/default.nix +++ b/hosts/ooksdesk/default.nix @@ -1,8 +1,4 @@ -{ lib, pkgs, ... }: - -let - key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBn3ff3HaZHIyH4K13k8Mwqu/o7jIABJ8rANK+r2PfJk"; -in +{ lib, pkgs, keys, ... }: { imports = [ @@ -17,7 +13,7 @@ in admin = { name = "ooks"; shell = "fish"; - sshKey = key; + sshKey = "${keys.users.ooks}"; homeManager = true; }; networking = { diff --git a/outputs/nixos.nix b/outputs/nixos.nix index 3ab1d5c..0fb7a0f 100644 --- a/outputs/nixos.nix +++ b/outputs/nixos.nix @@ -1,64 +1,66 @@ -{ inputs, self, ... }: +{ inputs, self, withSystem, ... }: let inherit (inputs.nixpkgs.lib) nixosSystem; + inherit (self) keys; hm = inputs.home-manager.nixosModules.home-manager; nixarr = inputs.nixarr.nixosModules.default; + agenix = inputs.agenix.nixosModules.default; nixosModules = "${self}/nixos"; hosts = "${self}/hosts"; - specialArgs = {inherit inputs self;}; + specialArgs = {inherit withSystem keys inputs self;}; in { - flake.nixosConfigurations = { - ooksdesk = nixosSystem { - inherit specialArgs; - system = "x86_64-linux"; - modules = [ - "${hosts}/ooksdesk" - hm - nixosModules - ]; - }; - ookst480s = nixosSystem { - inherit specialArgs; - system = "x86_64-linux"; - modules = [ - "${hosts}/ookst480s" - hm - nixosModules - ]; - }; - ooksmedia = nixosSystem { - inherit specialArgs; - system = "x86_64-linux"; - modules = [ - "${hosts}/ooksmedia" - hm - nixosModules - nixarr - ]; - }; - ooksmicro = nixosSystem { - inherit specialArgs; - system = "x86_64-linux"; - modules = [ - "${hosts}/ooksmicro" - hm - nixosModules - ]; - }; - ooksx1 = nixosSystem { - inherit specialArgs; - system = "x86_64-linux"; - modules = [ - "${hosts}/ooksx1" - hm - nixosModules - ]; - }; + ooksdesk = nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + "${hosts}/ooksdesk" + hm + agenix + + nixosModules + ]; + }; + ookst480s = nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + "${hosts}/ookst480s" + hm + nixosModules + ]; + }; + ooksmedia = nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + "${hosts}/ooksmedia" + hm + nixosModules + nixarr + ]; + }; + ooksmicro = nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + "${hosts}/ooksmicro" + hm + nixosModules + ]; + }; + ooksx1 = nixosSystem { + inherit specialArgs; + system = "x86_64-linux"; + modules = [ + "${hosts}/ooksx1" + hm + nixosModules + ]; }; } diff --git a/outputs/shell.nix b/outputs/shell.nix deleted file mode 100644 index 8a04807..0000000 --- a/outputs/shell.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs ? (import ./nixpkgs.nix) { } }: { - default = pkgs.mkShell { - # Enable experimental features without having to specify the argument - NIX_CONFIG = "experimental-features = nix-command flakes"; - nativeBuildInputs = with pkgs; [ nix home-manager git neovim ]; - }; -}