Compare commits
18 commits
main
...
export-nix
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 0fb2ed977e | ||
Bruno BELANYI | c593180cf2 | ||
Bruno BELANYI | d94c9da1c1 | ||
Bruno BELANYI | e33357f72e | ||
Bruno BELANYI | dd7134ca3e | ||
Bruno BELANYI | 33a7d0a141 | ||
Bruno BELANYI | 272a8fb7b9 | ||
Bruno BELANYI | ad17fed0bf | ||
Bruno BELANYI | 334a3346b8 | ||
Bruno BELANYI | 53594d2fb4 | ||
Bruno BELANYI | 9f82f2a7e8 | ||
Bruno BELANYI | ac03fb3b31 | ||
Bruno BELANYI | 034cd3ac55 | ||
Bruno BELANYI | 2027bb327e | ||
Bruno BELANYI | 61c234d932 | ||
Bruno BELANYI | fe6df44b85 | ||
Bruno BELANYI | d113742905 | ||
Bruno BELANYI | aa1336bb8d |
|
@ -13,6 +13,7 @@ flake-parts.lib.mkFlake { inherit inputs; } {
|
|||
./checks.nix
|
||||
./dev-shells.nix
|
||||
./home-manager.nix
|
||||
./hosts.nix
|
||||
./lib.nix
|
||||
./nixos.nix
|
||||
./overlays.nix
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{ self, inputs, lib, ... }:
|
||||
{ self, config, inputs, lib, ... }:
|
||||
let
|
||||
inherit (config) hosts;
|
||||
|
||||
defaultModules = [
|
||||
# Include generic settings
|
||||
"${self}/modules/home"
|
||||
|
@ -14,9 +16,11 @@ let
|
|||
# Enable home-manager
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
# Import common modules
|
||||
"${self}/modules/common"
|
||||
];
|
||||
|
||||
mkHome = name: system: inputs.home-manager.lib.homeManagerConfiguration {
|
||||
mkHomeCommon = mainModules: system: inputs.home-manager.lib.homeManagerConfiguration {
|
||||
# Work-around for home-manager
|
||||
# * not letting me set `lib` as an extraSpecialArgs
|
||||
# * not respecting `nixpkgs.overlays` [1]
|
||||
|
@ -29,34 +33,51 @@ let
|
|||
];
|
||||
};
|
||||
|
||||
modules = defaultModules ++ [
|
||||
"${self}/hosts/homes/${name}"
|
||||
];
|
||||
modules = defaultModules ++ mainModules;
|
||||
|
||||
extraSpecialArgs = {
|
||||
# Inject inputs to use them in global registry
|
||||
inherit inputs;
|
||||
# For consumption by common modules
|
||||
type = "home";
|
||||
};
|
||||
};
|
||||
|
||||
homes = {
|
||||
mkHome = name: mkHomeCommon [ "${self}/hosts/homes/${name}" ];
|
||||
|
||||
mkNixosHome = name: mkHomeCommon [
|
||||
"${self}/hosts/nixos/${name}/home.nix"
|
||||
"${self}/hosts/nixos/${name}/profiles.nix"
|
||||
];
|
||||
in
|
||||
{
|
||||
hosts.homes = {
|
||||
"ambroisie@bazin" = "x86_64-linux";
|
||||
"ambroisie@mousqueton" = "x86_64-linux";
|
||||
};
|
||||
in
|
||||
{
|
||||
|
||||
perSystem = { system, ... }: {
|
||||
# Work-around for https://github.com/nix-community/home-manager/issues/3075
|
||||
legacyPackages = {
|
||||
homeConfigurations =
|
||||
let
|
||||
filteredHomes = lib.filterAttrs (_: v: v == system) homes;
|
||||
filteredHomes = lib.filterAttrs (_: v: v == system) hosts.homes;
|
||||
allHomes = filteredHomes // {
|
||||
# Default configuration
|
||||
ambroisie = system;
|
||||
};
|
||||
homeManagerHomes = lib.mapAttrs mkHome allHomes;
|
||||
|
||||
filteredNixosHosts = lib.filterAttrs (_: v: v == system) hosts.nixos;
|
||||
nixosHomes' = lib.mapAttrs mkNixosHome filteredNixosHosts;
|
||||
nixosHomeUsername = (host: self.nixosConfigurations.${host}.config.my.user.name);
|
||||
nixosHomes = lib.mapAttrs' (host: lib.nameValuePair "${nixosHomeUsername host}@${host}") nixosHomes';
|
||||
in
|
||||
lib.mapAttrs mkHome allHomes;
|
||||
lib.foldl' lib.mergeAttrs { }
|
||||
[
|
||||
homeManagerHomes
|
||||
nixosHomes
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
21
flake/hosts.nix
Normal file
21
flake/hosts.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Define `hosts.{darwin,home,nixos}` options for consumption in other modules
|
||||
{ lib, ... }:
|
||||
let
|
||||
mkHostsOption = description: lib.mkOption {
|
||||
inherit description;
|
||||
type = with lib.types; attrsOf str;
|
||||
default = { };
|
||||
example = { name = "x86_64-linux"; };
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
hosts = {
|
||||
darwin = mkHostsOption "Darwin hosts";
|
||||
|
||||
homes = mkHostsOption "Home Manager hosts";
|
||||
|
||||
nixos = mkHostsOption "NixOS hosts";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
{ self, inputs, lib, ... }:
|
||||
{ self, config, inputs, lib, ... }:
|
||||
let
|
||||
defaultModules = [
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ let
|
|||
}
|
||||
# Include generic settings
|
||||
"${self}/modules/nixos"
|
||||
# Import common modules
|
||||
"${self}/modules/common"
|
||||
];
|
||||
|
||||
buildHost = name: system: lib.nixosSystem {
|
||||
|
@ -24,12 +26,18 @@ let
|
|||
inherit (self) lib;
|
||||
# Inject inputs to use them in global registry
|
||||
inherit inputs;
|
||||
# For consumption by common modules
|
||||
type = "nixos";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
flake.nixosConfigurations = lib.mapAttrs buildHost {
|
||||
aramis = "x86_64-linux";
|
||||
porthos = "x86_64-linux";
|
||||
config = {
|
||||
hosts.nixos = {
|
||||
aramis = "x86_64-linux";
|
||||
porthos = "x86_64-linux";
|
||||
};
|
||||
|
||||
flake.nixosConfigurations = lib.mapAttrs buildHost config.hosts.nixos;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
./hardware.nix
|
||||
./home.nix
|
||||
./networking.nix
|
||||
./profiles.nix
|
||||
./secrets
|
||||
./services.nix
|
||||
./system.nix
|
||||
|
|
4
hosts/nixos/porthos/profiles.nix
Normal file
4
hosts/nixos/porthos/profiles.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{ ... }:
|
||||
{
|
||||
# Nothing
|
||||
}
|
35
modules/common/default.nix
Normal file
35
modules/common/default.nix
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Modules that are common to various module systems
|
||||
# Usually with very small differences, if any, between them.
|
||||
{ lib, type ? null, ... }:
|
||||
let
|
||||
allowedTypes = [
|
||||
"darwin"
|
||||
"home"
|
||||
"nixos"
|
||||
];
|
||||
|
||||
allowedTypesString = lib.concatStringSep ", " (builtins.map lib.escapeNixString allowedTypes);
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./profiles
|
||||
];
|
||||
|
||||
config = {
|
||||
assertions = [
|
||||
{
|
||||
assertion = type != null;
|
||||
message = ''
|
||||
You must provide `type` as part of specialArgs to use the common modules.
|
||||
It must be one of ${allowedTypesString}.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = type != null -> builtins.elem type allowedTypes;
|
||||
message = ''
|
||||
`type` specialArgs must be one of ${allowedTypesString}.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
19
modules/common/profiles/bluetooth/default.nix
Normal file
19
modules/common/profiles/bluetooth/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ config, lib, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.bluetooth;
|
||||
in
|
||||
{
|
||||
options.my.profiles.bluetooth = with lib; {
|
||||
enable = mkEnableOption "bluetooth profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.optionalAttrs (type == "home") {
|
||||
my.home.bluetooth.enable = true;
|
||||
})
|
||||
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
my.hardware.bluetooth.enable = true;
|
||||
})
|
||||
]);
|
||||
}
|
25
modules/common/profiles/default.nix
Normal file
25
modules/common/profiles/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Configuration that spans accross system and home, or are almagations of modules
|
||||
{ config, lib, type, ... }:
|
||||
{
|
||||
imports = [
|
||||
./bluetooth
|
||||
./devices
|
||||
./gtk
|
||||
./laptop
|
||||
./wm
|
||||
./x
|
||||
];
|
||||
|
||||
config = lib.mkMerge [
|
||||
# Transparently enable home-manager profiles as well
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
home-manager.users.${config.my.user.name} = {
|
||||
config = {
|
||||
my = {
|
||||
inherit (config.my) profiles;
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
22
modules/common/profiles/devices/default.nix
Normal file
22
modules/common/profiles/devices/default.nix
Normal file
|
@ -0,0 +1,22 @@
|
|||
{ config, lib, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.devices;
|
||||
in
|
||||
{
|
||||
options.my.profiles.devices = with lib; {
|
||||
enable = mkEnableOption "devices profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
my.hardware = {
|
||||
ergodox.enable = true;
|
||||
|
||||
mx-ergo.enable = true;
|
||||
};
|
||||
|
||||
# MTP devices auto-mount via file explorers
|
||||
services.gvfs.enable = true;
|
||||
})
|
||||
]);
|
||||
}
|
21
modules/common/profiles/gtk/default.nix
Normal file
21
modules/common/profiles/gtk/default.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ config, lib, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.gtk;
|
||||
in
|
||||
{
|
||||
options.my.profiles.gtk = with lib; {
|
||||
enable = mkEnableOption "gtk profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.optionalAttrs (type == "home") {
|
||||
# GTK theme configuration
|
||||
my.home.gtk.enable = true;
|
||||
})
|
||||
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
# Allow setting GTK configuration using home-manager
|
||||
programs.dconf.enable = true;
|
||||
})
|
||||
]);
|
||||
}
|
27
modules/common/profiles/laptop/default.nix
Normal file
27
modules/common/profiles/laptop/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ config, lib, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.laptop;
|
||||
in
|
||||
{
|
||||
options.my.profiles.laptop = with lib; {
|
||||
enable = mkEnableOption "laptop profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.optionalAttrs (type == "home") {
|
||||
# Enable battery notifications
|
||||
my.home.power-alert.enable = true;
|
||||
})
|
||||
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
# Enable touchpad support
|
||||
services.xserver.libinput.enable = true;
|
||||
|
||||
# Enable TLP power management
|
||||
my.services.tlp.enable = true;
|
||||
|
||||
# Enable upower power management
|
||||
my.hardware.upower.enable = true;
|
||||
})
|
||||
]);
|
||||
}
|
36
modules/common/profiles/wm/default.nix
Normal file
36
modules/common/profiles/wm/default.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.wm;
|
||||
|
||||
applyWm = wm: configs: lib.mkIf (cfg.windowManager == wm) (lib.my.merge configs);
|
||||
in
|
||||
{
|
||||
options.my.profiles.wm = with lib; {
|
||||
windowManager = mkOption {
|
||||
type = with types; nullOr (enum [ "i3" ]);
|
||||
default = null;
|
||||
example = "i3";
|
||||
description = "Which window manager to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(applyWm "i3" [
|
||||
(lib.optionalAttrs (type == "home") {
|
||||
# i3 settings
|
||||
my.home.wm.windowManager = "i3";
|
||||
# Screenshot tool
|
||||
my.home.flameshot.enable = true;
|
||||
# Auto disk mounter
|
||||
my.home.udiskie.enable = true;
|
||||
})
|
||||
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
# Enable i3
|
||||
services.xserver.windowManager.i3.enable = true;
|
||||
# udiskie fails if it can't find this dbus service
|
||||
services.udisks2.enable = true;
|
||||
})
|
||||
])
|
||||
];
|
||||
}
|
27
modules/common/profiles/x/default.nix
Normal file
27
modules/common/profiles/x/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ config, lib, pkgs, type, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.x;
|
||||
in
|
||||
{
|
||||
options.my.profiles.x = with lib; {
|
||||
enable = mkEnableOption "X profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
(lib.optionalAttrs (type == "home") {
|
||||
# X configuration
|
||||
my.home.x.enable = true;
|
||||
})
|
||||
|
||||
(lib.optionalAttrs (type == "nixos") {
|
||||
# Enable the X11 windowing system.
|
||||
services.xserver.enable = true;
|
||||
# Nice wallpaper
|
||||
services.xserver.displayManager.lightdm.background =
|
||||
let
|
||||
wallpapers = "${pkgs.plasma5Packages.plasma-workspace-wallpapers}/share/wallpapers";
|
||||
in
|
||||
"${wallpapers}/summer_1am/contents/images/2560x1600.jpg";
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -5,7 +5,6 @@
|
|||
imports = [
|
||||
./hardware
|
||||
./home
|
||||
./profiles
|
||||
./programs
|
||||
./secrets
|
||||
./services
|
||||
|
|
|
@ -13,16 +13,23 @@ in
|
|||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home-manager = {
|
||||
# Not a fan of out-of-directory imports, but this is a good exception
|
||||
users.${config.my.user.name} = import "${inputs.self}/modules/home";
|
||||
users.${config.my.user.name} = {
|
||||
# Not a fan of out-of-directory imports, but this is a good exception
|
||||
imports = [
|
||||
"${inputs.self}/modules/common"
|
||||
"${inputs.self}/modules/home"
|
||||
];
|
||||
};
|
||||
|
||||
# Nix Flakes compatibility
|
||||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
|
||||
# Forward inputs to home-manager configuration
|
||||
extraSpecialArgs = {
|
||||
# Forward inputs to home-manager configuration
|
||||
inherit inputs;
|
||||
# For consumption by common modules
|
||||
type = "home";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.bluetooth;
|
||||
in
|
||||
{
|
||||
options.my.profiles.bluetooth = with lib; {
|
||||
enable = mkEnableOption "bluetooth profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hardware.bluetooth.enable = true;
|
||||
|
||||
my.home.bluetooth.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
# Configuration that spans accross system and home, or are almagations of modules
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./bluetooth
|
||||
./devices
|
||||
./gtk
|
||||
./laptop
|
||||
./wm
|
||||
./x
|
||||
];
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.devices;
|
||||
in
|
||||
{
|
||||
options.my.profiles.devices = with lib; {
|
||||
enable = mkEnableOption "devices profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
my.hardware = {
|
||||
ergodox.enable = true;
|
||||
|
||||
mx-ergo.enable = true;
|
||||
};
|
||||
|
||||
# MTP devices auto-mount via file explorers
|
||||
services.gvfs.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.gtk;
|
||||
in
|
||||
{
|
||||
options.my.profiles.gtk = with lib; {
|
||||
enable = mkEnableOption "gtk profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Allow setting GTK configuration using home-manager
|
||||
programs.dconf.enable = true;
|
||||
|
||||
# GTK theme configuration
|
||||
my.home.gtk.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.laptop;
|
||||
in
|
||||
{
|
||||
options.my.profiles.laptop = with lib; {
|
||||
enable = mkEnableOption "laptop profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Enable touchpad support
|
||||
services.xserver.libinput.enable = true;
|
||||
|
||||
# Enable TLP power management
|
||||
my.services.tlp.enable = true;
|
||||
|
||||
# Enable upower power management
|
||||
my.hardware.upower.enable = true;
|
||||
|
||||
# Enable battery notifications
|
||||
my.home.power-alert.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
{ config, lib, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.wm;
|
||||
in
|
||||
{
|
||||
options.my.profiles.wm = with lib; {
|
||||
windowManager = mkOption {
|
||||
type = with types; nullOr (enum [ "i3" ]);
|
||||
default = null;
|
||||
example = "i3";
|
||||
description = "Which window manager to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf (cfg.windowManager == "i3") {
|
||||
# Enable i3
|
||||
services.xserver.windowManager.i3.enable = true;
|
||||
# i3 settings
|
||||
my.home.wm.windowManager = "i3";
|
||||
# Screenshot tool
|
||||
my.home.flameshot.enable = true;
|
||||
# Auto disk mounter
|
||||
my.home.udiskie.enable = true;
|
||||
# udiskie fails if it can't find this dbus service
|
||||
services.udisks2.enable = true;
|
||||
})
|
||||
];
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
cfg = config.my.profiles.x;
|
||||
in
|
||||
{
|
||||
options.my.profiles.x = with lib; {
|
||||
enable = mkEnableOption "X profile";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
# Enable the X11 windowing system.
|
||||
services.xserver.enable = true;
|
||||
# Nice wallpaper
|
||||
services.xserver.displayManager.lightdm.background =
|
||||
let
|
||||
wallpapers = "${pkgs.plasma5Packages.plasma-workspace-wallpapers}/share/wallpapers";
|
||||
in
|
||||
"${wallpapers}/summer_1am/contents/images/2560x1600.jpg";
|
||||
|
||||
# X configuration
|
||||
my.home.x.enable = true;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue