From f5bc46061bb774820b46f1767bbc83673f527441 Mon Sep 17 00:00:00 2001 From: cy Date: Fri, 13 Dec 2024 11:27:01 -0500 Subject: [PATCH] some restructuring --- nix/flake.nix | 35 ++++++++++++++----- .../home.nix => home/yt/ytnix.nix} | 2 -- .../ytnix/default.nix} | 12 ++----- .../ytnix}/hardware-configuration.nix | 0 nix/{secrets => hosts/ytnix}/secrets.yaml | 0 5 files changed, 28 insertions(+), 21 deletions(-) rename nix/{home-manager/home.nix => home/yt/ytnix.nix} (98%) rename nix/{nixos/configuration.nix => hosts/ytnix/default.nix} (97%) rename nix/{nixos => hosts/ytnix}/hardware-configuration.nix (100%) rename nix/{secrets => hosts/ytnix}/secrets.yaml (100%) diff --git a/nix/flake.nix b/nix/flake.nix index dca1756..654bd69 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -17,34 +17,51 @@ outputs = { self, nixpkgs, - sops-nix, home-manager, ... }@inputs: let lib = nixpkgs.lib; - system = "x86_64-linux"; inherit (self) outputs; + + systems = [ "x86_64-linux" ]; + forEachSystem = f: lib.genAttrs systems (system: f pkgsFor.${system}); + pkgsFor = lib.genAttrs systems ( + system: + import nixpkgs { + inherit system; + config.allowUnfree = true; + } + ); in { - packages = import ./pkgs nixpkgs.legacyPackages.${system}; - formatter = nixpkgs.legacyPackages.${system}.nixpkgs-fmt; + packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); + formatter = forEachSystem (pkgs: pkgs.alejandra); + devShells = forEachSystem (pkgs: import ./shells { inherit pkgs; }); + nixosModules = import ./modules/nixos; + homeManagerModules = import ./modules/home-manager; + overlays = import ./overlays {inherit inputs outputs;}; - nixosConfigurations = { + nixosConfigurations = let + pkgs = pkgsFor.x86_64-linux; + in { ytnix = lib.nixosSystem { specialArgs = { inherit inputs outputs; }; modules = [ - ./nixos/configuration.nix - sops-nix.nixosModules.sops + { + nixpkgs = {inherit pkgs;}; + } + ./hosts/ytnix + inputs.sops-nix.nixosModules.sops ]; }; }; homeConfigurations = { "yt@ytnix" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = pkgsFor.x86_64-linux; extraSpecialArgs = { inherit inputs outputs; }; modules = [ - ./home-manager/home.nix + ./home/yt/ytnix.nix ]; }; }; diff --git a/nix/home-manager/home.nix b/nix/home/yt/ytnix.nix similarity index 98% rename from nix/home-manager/home.nix rename to nix/home/yt/ytnix.nix index 9d5c31f..c1a3a3c 100644 --- a/nix/home-manager/home.nix +++ b/nix/home/yt/ytnix.nix @@ -126,8 +126,6 @@ nextcloud-client python312Packages.python-lsp-server gopls - - (callPackage ../pkgs/anki-bin.nix {}) ]; programs.waybar.enable = true; diff --git a/nix/nixos/configuration.nix b/nix/hosts/ytnix/default.nix similarity index 97% rename from nix/nixos/configuration.nix rename to nix/hosts/ytnix/default.nix index e781828..1f277cc 100644 --- a/nix/nixos/configuration.nix +++ b/nix/hosts/ytnix/default.nix @@ -10,15 +10,7 @@ ./hardware-configuration.nix ]; - nixpkgs = { - config = { - allowUnfree = true; - }; - }; - - nix = let - flakeInputs = lib.filterAttrs (_: lib.isType "flake") inputs; - in { + nix = { settings = { experimental-features = "nix-command flakes"; auto-optimise-store = true; @@ -37,7 +29,7 @@ }; }; - sops.defaultSopsFile = ../secrets/secrets.yaml; + sops.defaultSopsFile = ./secrets.yaml; sops.defaultSopsFormat = "yaml"; sops.age.keyFile = "/root/.config/sops/age/keys.txt"; sops.secrets = { diff --git a/nix/nixos/hardware-configuration.nix b/nix/hosts/ytnix/hardware-configuration.nix similarity index 100% rename from nix/nixos/hardware-configuration.nix rename to nix/hosts/ytnix/hardware-configuration.nix diff --git a/nix/secrets/secrets.yaml b/nix/hosts/ytnix/secrets.yaml similarity index 100% rename from nix/secrets/secrets.yaml rename to nix/hosts/ytnix/secrets.yaml