Auto-import modules
This commit is contained in:
parent
3c1b9bc7a9
commit
9253d98ec7
|
@ -80,7 +80,8 @@ This config uses two systems: Flakes, and Home-manager.
|
||||||
- Flakes are the entrypoint, via `flake.nix`. This is where you include Flake modules and define Flake-specific options.
|
- Flakes are the entrypoint, via `flake.nix`. This is where you include Flake modules and define Flake-specific options.
|
||||||
- Home-manager configs live in the `users/` folders. Each user gets its own `home-manager.nix` file too.
|
- Home-manager configs live in the `users/` folders. Each user gets its own `home-manager.nix` file too.
|
||||||
- Modules are stored in `modules`. All of these files are imported, and you enable the ones you want to use. For example, to install Flatpak, set `host.ui.flatpak.enable = true;`.
|
- Modules are stored in `modules`. All of these files are imported, and you enable the ones you want to use. For example, to install Flatpak, set `host.ui.flatpak.enable = true;`.
|
||||||
- After adding a new module, make sure to `git add` it _and_ `import` it in `default.nix`.
|
- After adding a new module, make sure to `git add` it.
|
||||||
|
- Modules are automatically imported - see `autoimport.nix`.
|
||||||
|
|
||||||
### Adding a host
|
### Adding a host
|
||||||
|
|
||||||
|
|
37
flake.lock
37
flake.lock
|
@ -235,40 +235,6 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1714404219,
|
|
||||||
"narHash": "sha256-1YdyaIv7WM3snp3E5Ib4Fsr4Z6/IbR5aKqVo3VXkfEA=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "aa30bcc07ba66e96bb6467e4a42f7845f11b6942",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "master",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nypkgs": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1714404288,
|
|
||||||
"narHash": "sha256-CTGtSlkTtETcDbt61jtXqIIy89Fzf/+8aEClPO/bcAg=",
|
|
||||||
"owner": "yunfachi",
|
|
||||||
"repo": "nypkgs",
|
|
||||||
"rev": "27648b0d368a565ff415fcd240056b41a97c0e7b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "yunfachi",
|
|
||||||
"repo": "nypkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"pre-commit-hooks-nix": {
|
"pre-commit-hooks-nix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-compat": [
|
"flake-compat": [
|
||||||
|
@ -306,8 +272,7 @@
|
||||||
"lanzaboote": "lanzaboote",
|
"lanzaboote": "lanzaboote",
|
||||||
"nix-flatpak": "nix-flatpak",
|
"nix-flatpak": "nix-flatpak",
|
||||||
"nixos-hardware": "nixos-hardware",
|
"nixos-hardware": "nixos-hardware",
|
||||||
"nixpkgs": "nixpkgs_2",
|
"nixpkgs": "nixpkgs_2"
|
||||||
"nypkgs": "nypkgs"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
# Hardware configurations
|
# Hardware configurations
|
||||||
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
nixos-hardware.url = "github:NixOS/nixos-hardware";
|
||||||
|
|
||||||
# Auto-import modules
|
|
||||||
nypkgs.url = "github:yunfachi/nypkgs";
|
|
||||||
|
|
||||||
# Home-manager
|
# Home-manager
|
||||||
home-manager = {
|
home-manager = {
|
||||||
url = "github:nix-community/home-manager/master";
|
url = "github:nix-community/home-manager/master";
|
||||||
|
@ -28,7 +25,7 @@
|
||||||
# TODO: Add Disko - https://github.com/nix-community/disko
|
# TODO: Add Disko - https://github.com/nix-community/disko
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, nypkgs,... }:
|
outputs = inputs@{ self, nixpkgs, lanzaboote, nix-flatpak, home-manager, nixos-hardware, ... }:
|
||||||
let
|
let
|
||||||
forAllSystems = function:
|
forAllSystems = function:
|
||||||
nixpkgs.lib.genAttrs [
|
nixpkgs.lib.genAttrs [
|
||||||
|
@ -56,10 +53,6 @@
|
||||||
backupFileExtension = "home-manager-backup";
|
backupFileExtension = "home-manager-backup";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
nypkgs.ylib.umport {
|
|
||||||
paths = [ ../modules ];
|
|
||||||
recursive = true;
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
|
@ -10,6 +10,6 @@ let
|
||||||
in{
|
in{
|
||||||
imports = [
|
imports = [
|
||||||
"${nix-secrets}/default.nix"
|
"${nix-secrets}/default.nix"
|
||||||
../modules
|
../modules/autoimport.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./development.nix
|
|
||||||
./dj.nix
|
|
||||||
./gaming.nix
|
|
||||||
./kdeconnect.nix
|
|
||||||
./media.nix
|
|
||||||
./office.nix
|
|
||||||
./recording.nix
|
|
||||||
./social.nix
|
|
||||||
./writing.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -20,13 +20,16 @@ with lib;
|
||||||
"com.vscodium.codium"
|
"com.vscodium.codium"
|
||||||
"dev.k8slens.OpenLens"
|
"dev.k8slens.OpenLens"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
statix # Nix linting tool
|
||||||
|
];
|
||||||
})
|
})
|
||||||
(mkIf cfg.kubernetes.enable {
|
(mkIf cfg.kubernetes.enable {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
kubectl
|
kubectl
|
||||||
kubernetes-helm
|
kubernetes-helm
|
||||||
kubevirt # Virtctl command-line tool
|
kubevirt # Virtctl command-line tool
|
||||||
statix # Nix linting tool
|
|
||||||
];
|
];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
26
modules/autoimport.nix
Normal file
26
modules/autoimport.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Auto-import modules in this folder, recursively.
|
||||||
|
# Sourced from https://github.com/evanjs/nixos_cfg/blob/4bb5b0b84a221b25cf50853c12b9f66f0cad3ea4/config/new-modules/default.nix
|
||||||
|
{ lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
# Recursively constructs an attrset of a given folder, recursing on directories, value of attrs is the filetype
|
||||||
|
getDir = dir: mapAttrs
|
||||||
|
(file: type:
|
||||||
|
if type == "directory" then getDir "${dir}/${file}" else type
|
||||||
|
)
|
||||||
|
(builtins.readDir dir);
|
||||||
|
|
||||||
|
# Collects all files of a directory as a list of strings of paths
|
||||||
|
files = dir: collect isString (mapAttrsRecursive (path: type: concatStringsSep "/" path) (getDir dir));
|
||||||
|
|
||||||
|
# Filters out directories that belong to home-manager, and don't end with .nix or are this file.
|
||||||
|
# Also, make the strings absolute
|
||||||
|
validFiles = dir: map
|
||||||
|
(file: ./. + "/${file}")
|
||||||
|
(filter
|
||||||
|
(file: ! hasInfix "home-manager" file && file != "autoimport.nix" && hasSuffix ".nix" file)
|
||||||
|
(files dir));
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = validFiles ./.;
|
||||||
|
}
|
|
@ -1,11 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./bluetooth.nix
|
|
||||||
./bootloader.nix
|
|
||||||
./network.nix
|
|
||||||
./nix.nix
|
|
||||||
./programs.nix
|
|
||||||
./shell.nix
|
|
||||||
./system.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./apps
|
|
||||||
./base
|
|
||||||
./roles
|
|
||||||
./services
|
|
||||||
./ui
|
|
||||||
./users
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
{
|
{
|
||||||
imports = [
|
|
||||||
./server.nix
|
|
||||||
./workstation.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
host.role = mkOption {
|
host.role = mkOption {
|
||||||
type = types.enum [
|
type = types.enum [
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./apcupsd.nix
|
|
||||||
./btrfs.nix
|
|
||||||
./duplicacy-web.nix
|
|
||||||
./k3s.nix
|
|
||||||
./msmtp.nix
|
|
||||||
./smartd.nix
|
|
||||||
./systemd.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
{ ... }:
|
|
||||||
|
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./audio.nix
|
|
||||||
./flatpak.nix
|
|
||||||
./gnome.nix
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -44,8 +44,8 @@ with lib;
|
||||||
# Configure home-manager
|
# Configure home-manager
|
||||||
home-manager.users.aires = {
|
home-manager.users.aires = {
|
||||||
imports = [
|
imports = [
|
||||||
../common/gnome.nix
|
../common/home-manager/gnome.nix
|
||||||
../common/zsh.nix
|
../common/home-manager/zsh.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
{ ... }: {
|
|
||||||
imports = [
|
|
||||||
./aires
|
|
||||||
./gremlin
|
|
||||||
./media
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -43,8 +43,8 @@ with lib;
|
||||||
|
|
||||||
home-manager.users.gremlin = {
|
home-manager.users.gremlin = {
|
||||||
imports = [
|
imports = [
|
||||||
../common/gnome.nix
|
../common/home-manager/gnome.nix
|
||||||
../common/zsh.nix
|
../common/home-manager/zsh.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
home = {
|
home = {
|
||||||
|
|
Loading…
Reference in a new issue