diff --git a/flake.nix b/flake.nix index da6ec7d..0549156 100644 --- a/flake.nix +++ b/flake.nix @@ -1,12 +1,13 @@ { description = '' - My personal NixOS Flake templates! - For questions just DM me on X: https://twitter.com/@m3tam3re There is also some NIXOS content on my YT channel: https://www.youtube.com/@m3tam3re One of the best ways to learn NIXOS is to read other peoples configurations. I have personally learned a lot from Gabriel Fontes configs: https://github.com/Misterio77/nix-starter-configs + https://github.com/Misterio77/nix-config + + Please also check out the starter configs mentioned above. ''; inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; }; diff --git a/nixos/standard/flake.lock b/nixos/standard/flake.lock new file mode 100644 index 0000000..62a6880 --- /dev/null +++ b/nixos/standard/flake.lock @@ -0,0 +1,65 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1712016346, + "narHash": "sha256-O2nO7pD+krq+4HgkLB4VThRtAucIPfXDs/jJqCGlK1w=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "4be0464472675212654dedf3e021bd5f1d58b92f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1711668574, + "narHash": "sha256-u1dfs0ASQIEr1icTVrsKwg2xToIpn7ZXxW3RHfHxshg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nixos/standard/flake.nix b/nixos/standard/flake.nix index 2d34ee5..07ead24 100644 --- a/nixos/standard/flake.nix +++ b/nixos/standard/flake.nix @@ -1,5 +1,14 @@ { - description = "A very basic flake"; + description = '' + For questions just DM me on X: https://twitter.com/@m3tam3re + There is also some NIXOS content on my YT channel: https://www.youtube.com/@m3tam3re + + One of the best ways to learn NIXOS is to read other peoples configurations. I have personally learned a lot from Gabriel Fontes configs: + https://github.com/Misterio77/nix-starter-configs + https://github.com/Misterio77/nix-config + + Please also check out the starter configs mentioned above. + ''; inputs = { home-manager = { @@ -7,14 +16,36 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11"; }; - outputs = { self, home-manager, nixpkgs }@inputs: { - nixosConfigurations = { - your-host = nixpkgs.lib.nixosSystem { - specialArgs = { inherit inputs; }; - modules = [ ./hosts/your-host ]; + outputs = { self, home-manager, nixpkgs, ... }@inputs: + let + inherit (self) outputs; + systems = [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in { + packages = + forAllSystems (system: import ./pkgs nixpkgs.legacyPackages.${system}); + overlays = import ./overlays { inherit inputs; }; + nixosConfigurations = { + your-host = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; + modules = [ ./hosts/your-host ]; + }; + }; + homeConfigurations = { + "your-name@your-host" = home-manager.lib.homeManagerConfiguration { + pkgs = nixpkgs.legacyPackages."x86_64-linux"; + extraSpecialArgs = { inherit inputs outputs; }; + modules = [ ./home/your-name/your-host.nix ]; + }; }; }; - }; } diff --git a/nixos/standard/home/common/default.nix b/nixos/standard/home/common/default.nix index 4a9768b..8b31055 100644 --- a/nixos/standard/home/common/default.nix +++ b/nixos/standard/home/common/default.nix @@ -1,11 +1,11 @@ -{ config, lib, pkgs, ... }: { +{ config, lib, outputs, pkgs, ... }: { nixpkgs = { # You can add overlays here overlays = [ # Add overlays your own flake exports (from overlays and pkgs dir): - #outputs.overlays.additions - #outputs.overlays.modifications - #outputs.overlays.stable-packages + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.stable-packages # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default diff --git a/nixos/standard/hosts/common/default.nix b/nixos/standard/hosts/common/default.nix index d643f47..cc091c9 100644 --- a/nixos/standard/hosts/common/default.nix +++ b/nixos/standard/hosts/common/default.nix @@ -1,10 +1,38 @@ # Common configuration for all hosts -{ config, lib, inputs, ... }: { +{ lib, inputs, outputs, ... }: { + nixpkgs = { + # You can add overlays here + overlays = [ + # Add overlays your own flake exports (from overlays and pkgs dir): + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.stable-packages + + # You can also add overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + }; + }; + nix = { settings = { experimental-features = "nix-command flakes"; - trusted-users = [ "root" "m3tam3re" ]; + trusted-users = [ + "root" + "your-user" + ]; # Set users that are allowed to use the flake command }; gc = { automatic = true; diff --git a/nixos/standard/hosts/your-host/default.nix b/nixos/standard/hosts/your-host/default.nix index bda7aed..e263821 100644 --- a/nixos/standard/hosts/your-host/default.nix +++ b/nixos/standard/hosts/your-host/default.nix @@ -4,7 +4,7 @@ # # Please make sure to change the first couple of lines in your configuration.nix: -# { config, inputs, lib, pkgs, ... }: +# { config, inputs, ouputs, lib, pkgs, ... }: # # { # imports = [ # Include the results of the hardware scan. @@ -26,9 +26,15 @@ # # home-manager = { # useUserPackages = true; +# extraSpecialArgs = { inherit inputs outputs; }; # users.your-name = # import ../../home/your-name/${config.networking.hostName}.nix; # }; +# +# Please also change your hostname accordingly: +#:w + +# networking.hostName = "nixos"; # Define your hostname. { imports = [ ../common ./configuration.nix ]; diff --git a/nixos/standard/overlays/default.nix b/nixos/standard/overlays/default.nix new file mode 100644 index 0000000..ab3fc10 --- /dev/null +++ b/nixos/standard/overlays/default.nix @@ -0,0 +1,21 @@ +{ inputs, ... }: { + # This one brings our custom packages from the 'pkgs' directory + additions = final: _prev: import ../pkgs { pkgs = final; }; + + # This one contains whatever you want to overlay + # You can change versions, add patches, set compilation flags, anything really. + # https://nixos.wiki/wiki/Overlays + modifications = final: prev: + { + # example = prev.example.overrideAttrs (oldAttrs: rec { + # ... + # }); + }; + + stable-packages = final: _prev: { + stable = import inputs.nixpkgs-stable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/nixos/standard/pkgs/default.nix b/nixos/standard/pkgs/default.nix new file mode 100644 index 0000000..310dd6e --- /dev/null +++ b/nixos/standard/pkgs/default.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }: +{ + # Define your custom packages here + # my-package = pkgs.callPackage ./my-package {}; +} diff --git a/nixos/standard/pkgs/my-package/default.nix b/nixos/standard/pkgs/my-package/default.nix new file mode 100644 index 0000000..fe6ef0f --- /dev/null +++ b/nixos/standard/pkgs/my-package/default.nix @@ -0,0 +1,2 @@ +# Your custom nix-package +# ...