From 64fcff10aad9a5850d0bb537aca0eddcc8e404ae Mon Sep 17 00:00:00 2001 From: MFlossmann Date: Wed, 3 Jul 2024 00:37:56 +0200 Subject: [PATCH] Refactoring --- flake.nix | 47 ++++++++++++++++++++++++++----------------- helperLib/default.nix | 19 ++++++++++++----- overlays/default.nix | 12 +++++++++++ pkgs/default.nix | 5 +++++ 4 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 overlays/default.nix create mode 100644 pkgs/default.nix diff --git a/flake.nix b/flake.nix index 17d0b79..601623b 100644 --- a/flake.nix +++ b/flake.nix @@ -10,10 +10,10 @@ inputs.nixpkgs.follows = "nixpkgs"; }; - nixvim = { - url = "github:nix-community/nixvim"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + # nixvim = { + # url = "github:nix-community/nixvim"; + # inputs.nixpkgs.follows = "nixpkgs"; + # }; nixvim-config = { type = "gitlab"; owner = "MFlossmann"; @@ -31,24 +31,35 @@ }; }; - outputs = {...} @ inputs: let + outputs = { + self, + nixpkgs, + ... + } @ inputs: let # basic boilerplate-reducing lib with a bunch of functions helperLib = import ./helperLib/default.nix {inherit inputs;}; - in - with helperLib; { - nixosConfigurations = { - remus = mkSystem ./hosts/remus/configuration.nix; - }; + nixvim_config = inputs.nixvim_config; + in { + packages = helperLib.forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); - homeConfigurations = { - "prunebutt@remus" = mkHome "x86_64-linux" ./hosts/remus/home.nix; - }; + formatter = helperLib.forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); - homeManagerModules.default = ./modules/home; - nixosModules.default = ./modules/nixOS; + overlays = import ./overlays {inherit inputs;}; - overlays.additions = final: _prev: { - nixvim = nixvim-config.packages.${_prev.system}.default; - }; + nixosConfigurations = { + remus = helperLib.mkSystem ./hosts/remus/configuration.nix; }; + + homeConfigurations = { + "prunebutt@remus" = helperLib.mkHome "x86_64-linux" ./hosts/remus/home.nix; + }; + + homeManagerModules.default = ./modules/home; + nixosModules.default = ./modules/nixOS; + + # overlays.additions = + # (final: prev: { + # neovim = nixvim_config.packages.${prev.system}.default; + # }); + }; } diff --git a/helperLib/default.nix b/helperLib/default.nix index 0c90406..655f401 100644 --- a/helperLib/default.nix +++ b/helperLib/default.nix @@ -25,7 +25,11 @@ in rec { inherit inputs outputs helperLib; }; modules = [ - ({ config, pkgs, ... }: { nixpkgs.overlays = [ overlay-stable ]; }) + ({ + config, + pkgs, + ... + }: {nixpkgs.overlays = [overlay-stable];}) config outputs.nixosModules.default ]; @@ -38,7 +42,11 @@ in rec { inherit inputs helperLib outputs; }; modules = [ - ({ config, pkgs, ...}: { nixpkgs.overlays = [ overlay-stable ]; }) + ({ + config, + pkgs, + ... + }: {nixpkgs.overlays = [overlay-stable];}) config outputs.homeManagerModules.default ]; @@ -101,12 +109,13 @@ in rec { modules; # ============================ Shell ============================= # - forAllSystems = pkgs: + forAllSystems = + # pkgs: inputs.nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" - ] - (system: pkgs inputs.nixpkgs.legacyPackages.${system}); + ]; + # (system: pkgs inputs.nixpkgs.legacyPackages.${system}); } diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..1333740 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,12 @@ +{inputs, ...}: { + # This one brings our custom packages from the `pkgs` directory + additions = final: _prev: import ../pkgs final.pkgs; + + # Any custom modifications + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..d1c43a5 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,5 @@ +# Custom packages, that can be defined similarly to ones from nixpkgks +# Build them using `nix build .#example` +pkgs: { + # example = pkgs.callPackage ./example { }; +}