From 08f141e9793c0a28d34dd75383e758b62a34b7fe Mon Sep 17 00:00:00 2001 From: Gabriel Fontes Date: Wed, 1 Feb 2023 17:54:11 -0300 Subject: [PATCH] rework flake, move hydra stuff --- flake.nix | 48 +++++++++++++++--------------------------------- hydra.nix | 12 ++++++++++++ shell.nix | 22 ++++++++++++---------- 3 files changed, 39 insertions(+), 43 deletions(-) create mode 100644 hydra.nix diff --git a/flake.nix b/flake.nix index 81672227..661e666a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,14 @@ { description = "My NixOS configuration"; + nixConfig = { + extra-substituters = [ "https://cache.m7.rs" ]; + extra-trusted-public-keys = [ "cache.m7.rs:kszZ/NSwE/TjhOcPPQ16IuUiuRSisdiIwhKZCxguaWg=" ]; + }; + inputs = { - # Nix ecossystem nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-master.url = "github:nixos/nixpkgs/master"; hardware.url = "github:nixos/nixos-hardware"; impermanence.url = "github:nix-community/impermanence"; @@ -36,32 +41,22 @@ outputs = { self, nixpkgs, home-manager, ... }@inputs: let - inherit (nixpkgs.lib) filterAttrs; - inherit (builtins) mapAttrs elem; inherit (self) outputs; - notBroken = x: !(x.meta.broken or false); - supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; - forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + forEachSystem = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]; + forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys}); in - rec { - templates = import ./templates; + { nixosModules = import ./modules/nixos; homeManagerModules = import ./modules/home-manager; - overlays = import ./overlays; + templates = import ./templates; - packages = forAllSystems (system: - import ./pkgs { pkgs = nixpkgs.legacyPackages.${system}; } - ); - devShells = forAllSystems (system: { - default = nixpkgs.legacyPackages.${system}.callPackage ./shell.nix { }; - }); + overlays = import ./overlays { inherit inputs outputs; }; + hydraJobs = import ./hydra.nix { inherit inputs outputs; }; - hydraJobs = { - packages = mapAttrs (sys: filterAttrs (_: pkg: (elem sys pkg.meta.platforms && notBroken pkg))) packages; - nixos = mapAttrs (_: cfg: cfg.config.system.build.toplevel) nixosConfigurations; - }; + packages = forEachPkgs (pkgs: import ./pkgs { inherit pkgs; }); + devShells = forEachPkgs (pkgs: import ./shell.nix { inherit pkgs; }); - nixosConfigurations = rec { + nixosConfigurations = { # Desktop atlas = nixpkgs.lib.nixosSystem { specialArgs = { inherit inputs outputs; }; @@ -127,18 +122,5 @@ modules = [ ./home/misterio/generic.nix ]; }; }; - - nixConfig = { - extra-substituters = [ - "https://cache.m7.rs" - "https://hyprland.cachix.org" - "https://nix-community.cachix.org" - ]; - extra-trusted-public-keys = [ - "cache.m7.rs:kszZ/NSwE/TjhOcPPQ16IuUiuRSisdiIwhKZCxguaWg=" - "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; }; } diff --git a/hydra.nix b/hydra.nix new file mode 100644 index 00000000..c968d270 --- /dev/null +++ b/hydra.nix @@ -0,0 +1,12 @@ +{ inputs, outputs }: +let + inherit (inputs.nixpkgs.lib) filterAttrs mapAttrs elem; + + notBroken = pkg: !(pkg.meta.broken or false); + hasPlatform = sys: pkg: elem sys pkg.meta.platforms; + filterValidPkgs = sys: pkgs: filterAttrs (_: pkg: hasPlatform sys pkg && notBroken pkg); + getCfg = _: cfg: cfg.config.system.build.build.toplevel; +in { + packages = mapAttrs filterValidPkgs outputs.packages; + nixos = mapAttrs getCfg outputs.nixosConfigurations; +} diff --git a/shell.nix b/shell.nix index 9f80268c..99277ed5 100644 --- a/shell.nix +++ b/shell.nix @@ -9,15 +9,17 @@ }; in import nixpkgs { overlays = [ ]; } , ... -}: pkgs.mkShell { - NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake"; - nativeBuildInputs = with pkgs; [ - nix - home-manager - git +}: { + default = pkgs.mkShell { + NIX_CONFIG = "extra-experimental-features = nix-command flakes repl-flake"; + nativeBuildInputs = with pkgs; [ + nix + home-manager + git - sops - gnupg - age - ]; + sops + gnupg + age + ]; + }; }