From 15fb0cfd175149e137d62200efd230fc5c32f5fd Mon Sep 17 00:00:00 2001 From: madmin Date: Wed, 19 Jun 2024 15:11:54 +0200 Subject: [PATCH] Adding options for overlays, pkgs, internal library etc, checkout flake outputs to see interactions --- lib/default.nix | 24 ++++++++++++++++++++++++ modules/home-manager/default.nix | 6 ++++++ modules/nixos/default.nix | 6 ++++++ overlays/default.nix | 26 ++++++++++++++++++++++++++ pkgs/default.nix | 8 ++++++++ vars/default.nix | 13 +++++++++++++ vars/networking.nix | 2 ++ 7 files changed, 85 insertions(+) create mode 100644 lib/default.nix create mode 100644 modules/home-manager/default.nix create mode 100644 modules/nixos/default.nix create mode 100644 overlays/default.nix create mode 100644 pkgs/default.nix create mode 100644 vars/default.nix create mode 100644 vars/networking.nix diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..1cbd641 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,24 @@ +{ lib, ... }: +{ + # use path relative to the root of the project + relativeToRoot = lib.path.append ../.; + scanPaths = path: + builtins.map + (f: (path + "/${f}")) + (builtins.attrNames + (lib.attrsets.filterAttrs + ( + path: _type: + (_type == "directory") # include directories + || ( + # FIXME this barfs when child directories don't contain a default.nix + # example: + # error: getting status of '/nix/store/mx31x8530b758ap48vbg20qzcakrbc8 (see hosts/common/core/services/default.nix)a-source/hosts/common/core/services/default.nix': No such file or directory + # I created a blank default.nix in hosts/common/core/services to work around + (path != "default.nix") # ignore default.nix + && (lib.strings.hasSuffix ".nix" path) # include .nix files + ) + ) + (builtins.readDir path))); +} + diff --git a/modules/home-manager/default.nix b/modules/home-manager/default.nix new file mode 100644 index 0000000..45aae31 --- /dev/null +++ b/modules/home-manager/default.nix @@ -0,0 +1,6 @@ +# Add your reusable home-manager modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix new file mode 100644 index 0000000..8605069 --- /dev/null +++ b/modules/nixos/default.nix @@ -0,0 +1,6 @@ +# Add your reusable NixOS modules to this directory, on their own file (https://nixos.wiki/wiki/Module). +# These should be stuff you would like to share with others, not your personal configurations. +{ + # List your module files here + # my-module = import ./my-module.nix; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..669bd73 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,26 @@ +# +# This file defines overlays/custom modifications to upstream packages +# + +{ 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: let ... in { + # ... + # }); + }; + + # When applied, the unstable nixpkgs set (declared in the flake inputs) will + # be accessible through 'pkgs.unstable' + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix new file mode 100644 index 0000000..93794a4 --- /dev/null +++ b/pkgs/default.nix @@ -0,0 +1,8 @@ +# You can build these directly using 'nix build .#example' + +{ pkgs ? import { } }: rec { + + #################### Packages with external source #################### + + # name = pkgs.callPackage ./name { }; +} diff --git a/vars/default.nix b/vars/default.nix new file mode 100644 index 0000000..1c87139 --- /dev/null +++ b/vars/default.nix @@ -0,0 +1,13 @@ +{ inputs, lib }: +{ + username = "laozi"; + #domain = inputs.nix-secrets.domain; + #userFullName = inputs.nix-secrets.full-name; + #handle = "madmin"; + #userEmail = inputs.nix-secrets.user-email; + #gitEmail = "madmin@noreply.codeberg.org"; + #workEmail = inputs.nix-secrets.work-email; + #networking = import ./networking.nix { inherit lib; }; + persistFolder = "/persist"; + isMinimal = false; # Used to indicate nixos-installer build +} diff --git a/vars/networking.nix b/vars/networking.nix new file mode 100644 index 0000000..4b42ce7 --- /dev/null +++ b/vars/networking.nix @@ -0,0 +1,2 @@ +{ ... }: +{}