yep, more dotfiles

refactor: introduce fragments

+17 -4
README.md
···
# mrnossiom's NixOS and Home Manager configuration
+
# Options
+
+
```nix
+
{
+
local.fragment."name".enable = true; # bool; dictate whether to enable a fragment
+
+
local.option = {
+
onlyCached = true; # bool; dictate if you are to compile pkgs or use cache
+
};
+
}
+
```
+
# Bootstrap lightweight HM config
```
···
# Structure
- `apps`: Scripts serving dotfiles purposes
+
- `assets`: Media or files that don't fit in Nix files
- `home-manager`: Home Manager specific
-
- `assets`: Media or files that don't fit in Nix files
-
- `modules`: Opinionated HM configuration fragments
+
- `fragments`: Home Manager configuration fragments
+
- `options`: Home Manager configuration flags
- `profiles`: Base Home Manager configurations to build upon (e.g. `desktop`, `minimal`)
- `lib`: Additional custom lib and flake helpers
-
- `modules`: modules that fill a missing feature of NixOS or Home-Manager
+
- `modules`: modules that fill a missing feature of NixOS or Home Manager
- `nixos`: NixOS related config
- `hardware/<hostname>.nix`: Device-specific settings like settings generated by `nixos-generate-config`
- `layout/<layout>.nix`: `Disko` disk layouts used by `managedDiskLayout` (e.g `luks-btrfs`)
-
- `modules`: Opinionated NixOS configuration fragments
+
- `fragments`: Opinionated NixOS configuration fragments
- `profiles/<profile>.nix`: Base system configurations to build upon (e.g. `laptop`, `installer`)
- `overlays`: Just plain Nix overlays
- `pkgs`: Custom packages either not eligible or missing from repositories
-1
flake.nix
···
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
-
# Also see the 'unstable-packages' overlay at 'overlays/default.nix'.
home-manager.url = "github:nix-community/home-manager/release-24.05";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
home-manager/assets/BinaryCloud.png assets/wallpaper-binary-cloud.png
+1
home-manager/fragments/default.nix
···
+
{ ... }: { }
home-manager/modules/aws.nix home-manager/fragments/aws.nix
home-manager/modules/chromium.nix home-manager/fragments/chromium.nix
home-manager/modules/firefox.nix home-manager/fragments/firefox.nix
+5 -2
home-manager/modules/git.nix home-manager/fragments/git.nix
···
-
{ config
-
, lib
+
{ lib
, pkgs
, ...
}:
···
{
config = {
+
home.sessionVariables = {
+
GIT_DISCOVERY_ACROSS_FILESYSTEM = 0;
+
};
+
programs.git = {
enable = true;
lfs.enable = true;
home-manager/modules/helix.nix home-manager/fragments/helix.nix
home-manager/modules/imv.nix home-manager/fragments/imv.nix
home-manager/modules/shell.nix home-manager/fragments/shell.nix
home-manager/modules/thunderbird.nix home-manager/fragments/thunderbird.nix
home-manager/modules/tools.nix home-manager/fragments/tools.nix
home-manager/modules/vm/default.nix home-manager/fragments/vm/default.nix
home-manager/modules/vm/search.nix home-manager/fragments/vm/search.nix
home-manager/modules/vm/swaybar.nix home-manager/fragments/vm/swaybar.nix
home-manager/modules/vm/xcompose.nix home-manager/fragments/vm/xcompose.nix
home-manager/modules/vscodium.nix home-manager/fragments/vscodium.nix
home-manager/modules/zellij/config.kdl home-manager/fragments/zellij/config.kdl
home-manager/modules/zellij/default.nix home-manager/fragments/zellij/default.nix
+14
home-manager/options.nix
···
+
{ lib
+
, ...
+
}:
+
+
with lib;
+
+
{
+
options.local.onlyCached = mkOption {
+
description = "Whether to limit the number of pkgs to compile on device";
+
type = types.bool;
+
+
default = false;
+
};
+
}
+1 -1
home-manager/profiles/desktop.nix
···
# Nix colors
nix-colors.homeManagerModules.default
{ config.colorScheme = llib.colorSchemes.oneDark; }
-
] ++ map (modPath: ../modules/${modPath}) [
+
] ++ map (modPath: ../fragments/${modPath}) [
"aws.nix"
"chromium.nix"
"firefox.nix"
+3 -6
home-manager/profiles/lightweight.nix
···
let
_check = if (isDarwin) then throw "this is a HM non-darwin config" else null;
-
inherit (self.inputs) agenix nix-colors;
+
inherit (self.inputs) nix-colors;
toml-format = pkgs.formats.toml { };
in
···
# Nix colors
nix-colors.homeManagerModules.default
{ config.colorScheme = llib.colorSchemes.oneDark; }
-
] ++ map (modPath: ../modules/${modPath}) [
+
] ++ map (modPath: ../fragments/${modPath}) [
# "firefox.nix"
"git.nix"
"shell.nix"
···
];
config = {
-
# programs.home-manager.enable = osConfig == null;
+
programs.home-manager.enable = osConfig == null;
home = {
username = "milo.moisson";
···
hunspellDicts.fr-moderne
hunspellDicts.en_US-large
hunspellDicts.en_GB-large
-
-
# TUIs
-
# lpkgs.asak
# CLIs
wf-recorder
+1 -2
home-manager/profiles/macintosh.nix
···
, llib
, config
, pkgs
-
, upkgs
, isDarwin
# Provides the NixOS configuration if HM was loaded through the NixOS module
, osConfig ? null
···
# Nix colors
nix-colors.homeManagerModules.default
{ config.colorScheme = llib.colorSchemes.oneDark; }
-
] ++ map (modPath: ../modules/${modPath}) [
+
] ++ map (modPath: ../fragments/${modPath}) [
"aws.nix"
# "chromium.nix"
# "firefox.nix"
+10 -1
lib/default.nix
···
# This flake library is available to modules via the `llib` arg
-
pkgs: {
+
pkgs: with pkgs.lib; {
colorSchemes = import ./colorSchemes.nix;
+
+
createFragment = name: config: {
+
options."${name}".enable = mkOption {
+
description = "Whether to enable `${name}` fragment";
+
type = types.bool;
+
};
+
+
config = mkIf true config;
+
};
}
+18 -8
lib/flake/default.nix
···
rec {
forAllSystems = genAttrs [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
-
# - `self`: flake
-
# - `llib`: local flake library
-
# - `lpkgs`: local packages set
-
# - `upkgs`: unstable nixpkgs set
-
# - `isDarwin`: indicates if system is darwin
specialModuleArgs = pkgs: {
+
# this flake
inherit self;
+
# local flake library
llib = import ../. pkgs;
+
# local packages set
lpkgs = import ../../pkgs pkgs;
+
# unstable nixpkgs set
upkgs = import nixpkgs-unstable { inherit (pkgs) system config; };
+
# indicates if system is darwin
isDarwin = pkgs.stdenv.isDarwin;
};
createSystem = pkgs: modules: nixosSystem {
-
inherit pkgs modules;
+
inherit pkgs;
+
modules = modules ++ [
+
../../nixos/fragments/default.nix
+
];
specialArgs = specialModuleArgs pkgs;
};
···
managedDiskLayout = import ./managedDiskLayout.nix;
createHomeManager = pkgs: modules: homeManagerConfiguration {
-
inherit pkgs modules;
+
inherit pkgs;
+
modules = modules ++ [
+
../../home-manager/fragments/default.nix
+
../../home-manager/options.nix
+
];
extraSpecialArgs = (specialModuleArgs pkgs) // { osConfig = null; };
};
# Darwin related
darwin = {
createSystem = pkgs: modules: darwinSystem {
-
inherit pkgs modules;
+
inherit pkgs;
+
modules = modules ++ [
+
../../nixos/fragments/default.nix
+
];
specialArgs = specialModuleArgs pkgs;
};
+7 -1
lib/flake/user.nix
···
useUserPackages = false;
useGlobalPkgs = true;
-
users.${name} = import ../../home-manager/profiles/${profile}.nix;
+
users.${name} = { ... }: {
+
imports = [
+
../../home-manager/profiles/${profile}.nix
+
../../home-manager/fragments/default.nix
+
../../home-manager/options.nix
+
];
+
};
};
};
}
+1
nixos/fragments/default.nix
···
+
{ ... }: { }
nixos/modules/agenix.nix nixos/fragments/agenix.nix
nixos/modules/backup.nix nixos/fragments/backup.nix
nixos/modules/gaming.nix nixos/fragments/gaming.nix
nixos/modules/logiops.nix nixos/fragments/logiops.nix
nixos/modules/nix.nix nixos/fragments/nix.nix
nixos/modules/security.nix nixos/fragments/security.nix
nixos/modules/virtualisation.nix nixos/fragments/virtualisation.nix
+7
nixos/modules/wireless.nix nixos/fragments/wireless.nix
···
allowedTCPPortRanges = [
{ from = 42420; to = 42429; }
];
+
+
# Allow packets from Docker containers
+
# TODO: check if it actually works
+
extraCommands = ''
+
iptables -I INPUT 1 -s 172.16.0.0/12 -p tcp -d 172.17.0.1 -j ACCEPT
+
iptables -I INPUT 2 -s 172.16.0.0/12 -p udp -d 172.17.0.1 -j ACCEPT
+
'';
};
# Bluetooth
nixos/modules/yabai.nix nixos/fragments/yabai.nix
+2 -2
nixos/profiles/laptop.nix
···
imports = [
# Replaces nixpkgs module with a custom one that support fallback static location
nixosModules.geoclue2
-
] ++ map (modPath: ../modules/${modPath}) [
+
] ++ map (modPath: ../fragments/${modPath}) [
"agenix.nix"
"backup.nix"
"gaming.nix"
···
];
networking.hosts = {
-
"127.0.0.1" = [ "www.youtube.com" ];
+
# "127.0.0.1" = [ "www.youtube.com" ];
};
hardware.opengl = {
+1 -1
nixos/profiles/macintosh.nix
···
{
# Hardware is imported in the flake to be machine specific
-
imports = map (modPath: ../modules/${modPath}) [
+
imports = map (modPath: ../fragments/${modPath}) [
"agenix.nix"
# "logiops.nix"
"nix.nix"
+4 -10
templates/default.nix
···
blank = {
path = ./blank;
-
description = "Blank flake setup";
-
welcomeText = ''
-
You may want to run
-
$ direnv allow
-
'';
+
description = "Flake for default/blank setup";
+
welcomeText = "`direnv allow`";
};
rust = {
path = ./rust;
-
description = "Rust flake setup";
-
welcomeText = ''
-
You may want to run
-
$ direnv allow
-
'';
+
description = "Flake for Rust setup";
+
welcomeText = "`direnv allow`";
};
}