Skip to content

Commit

Permalink
feat: deployed toto
Browse files Browse the repository at this point in the history
  • Loading branch information
Swarsel committed Dec 24, 2024
1 parent 5637ab5 commit 32e2467
Show file tree
Hide file tree
Showing 15 changed files with 399 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .sops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ keys:
- &swarsel 4BE7925262289B476DBBC17B76FD3810215AE097
- &hosts
- &winters age1h72072slm2pthn9m2qwjsyy2dsazc6hz97kpzh4gksvv0r2jqecqul8w63
- &toto age1dmxw76fzr958zl23ad5h7gvtnurr8n5ajlqchgx76k6z5yj3z4zsn592fq
- &toto age16vzhcvz8tyxj8e0f47fy0z4p3dsg0ak4vl52ut3l07a0tz465cxslmhevl
- &surface age1zlnxraee6tddr07xn59mx5rdexw8qxryd53eqlsajasfhfy78fkq705dfg
- &nbl age16lnmuuxfuxxtty3atnhut8wseppwnhp7rdhmxqd5tdvs9qnjffjq42sqyy
- &sync age1glge4e97vgqzh332mqs5990vteezu2m8k4wq3z35jk0q8czw3gks2d7a3h
Expand Down
161 changes: 74 additions & 87 deletions SwarselSystems.org
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,10 @@ The interesting part is in the start:
systemFunc = func;
in
systemFunc {
specialArgs = { inherit inputs outputs self; };
specialArgs = {
inherit inputs outputs self;
lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; });
};
modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ];
};
};
Expand Down Expand Up @@ -1202,6 +1205,9 @@ My work machine. Built for more security, this is the gold standard of my config
{ self, inputs, outputs, config, pkgs, lib, ... }:
let
profilesPath = "${self}/profiles";
sharedOptions = {
isBtrfs = true;
};
in
{

Expand Down Expand Up @@ -1279,19 +1285,17 @@ My work machine. Built for more security, this is the gold standard of my config
'';
};

swarselsystems = {
swarselsystems = lib.recursiveUpdate {
wallpaper = self + /wallpaper/lenovowp.png;
hasBluetooth = true;
hasFingerprint = true;
impermanence = false;
isBtrfs = true;
isImpermanence = false;
isCrypted = true;
};
} sharedOptions;

home-manager.users.swarsel.swarselsystems = {
home-manager.users.swarsel.swarselsystems = lib.recursiveUpdate {
isLaptop = true;
isNixos = true;
isBtrfs = true;
flakePath = "/home/swarsel/.dotfiles";
cpuCount = 16;
# temperatureHwmon = {
Expand Down Expand Up @@ -1416,7 +1420,7 @@ My work machine. Built for more security, this is the gold standard of my config
ans = ". ~/.venvs/ansible/bin/activate";
ans2-15 = ". ~/.venvs/ansible2.15.0/bin/activate";
};
};
} sharedOptions;
}


Expand Down Expand Up @@ -1478,7 +1482,7 @@ This is my main server that I run at home. It handles most tasks that require bi
swarselsystems = {
hasBluetooth = false;
hasFingerprint = false;
impermanence = false;
isImpermanence = false;
isBtrfs = false;
flakePath = "/home/swarsel/.dotfiles";
server = {
Expand Down Expand Up @@ -1713,7 +1717,7 @@ This machine mainly acts as an external sync helper. It manages the following th
swarselsystems = {
hasBluetooth = false;
hasFingerprint = false;
impermanence = false;
isImpermanence = false;
isBtrfs = false;
flakePath = "/root/.dotfiles";
server = {
Expand All @@ -1735,21 +1739,15 @@ This is a slim setup for developing base configuration.
{ self, inputs, outputs, config, pkgs, lib, ... }:
let
profilesPath = "${self}/profiles";
sharedOptions = {
isBtrfs = true;
};
in
{

imports = [
inputs.disko.nixosModules.disko
"${self}/hosts/nixos/toto/disk-config.nix"
{
_module.args = {
withSwap = true;
swapSize = "8";
rootDisk = "/dev/vda";
withImpermanence = true;
withEncryption = true;
};
}
./hardware-configuration.nix

inputs.sops-nix.nixosModules.sops
Expand Down Expand Up @@ -1810,20 +1808,21 @@ This is a slim setup for developing base configuration.
firewall.enable = false;
};

swarselsystems = {
swarselsystems = lib.recursiveUpdate {
wallpaper = self + /wallpaper/lenovowp.png;
impermanence = true;
isBtrfs = true;
isImpermanence = true;
isCrypted = true;
initialSetup = true;
};
isSwap = true;
swapSize = "8G";
rootDisk = "/dev/vda";
} sharedOptions;

home-manager.users.swarsel.swarselsystems = {
home-manager.users.swarsel.swarselsystems = lib.recursiveUpdate {
isLaptop = false;
isNixos = true;
isBtrfs = true;
flakePath = "/home/swarsel/.dotfiles";
};
} sharedOptions;

}

Expand Down Expand Up @@ -3533,23 +3532,22 @@ Note: The structure of generating the packages was changed in commit =2cf03a3 re
Modules that need to be loaded on the NixOS level. Note that these will not be available on systems that are not running NixOS.

#+begin_src nix :tangle modules/nixos/default.nix
let
moduleNames = [
"wallpaper"
"hardware"
"setup"
"impermanence"
"filesystem"
"input"
];
let
moduleNames = [
"wallpaper"
"hardware"
"setup"
"server"
"input"
];

mkImports = names: builtins.listToAttrs (map (name: {
inherit name;
value = import ./${name}.nix;
}) names);
mkImports = names: builtins.listToAttrs (map (name: {
inherit name;
value = import ./${name}.nix;
}) names);

in
mkImports moduleNames
in
mkImports moduleNames

#+end_src

Expand Down Expand Up @@ -3603,22 +3601,45 @@ I usually use =mutableUsers = false= in my NixOS configuration. However, on a ne

#+begin_src nix :tangle modules/nixos/setup.nix
{ lib, ... }:
let
inherit (lib) mkOption types;
in

{
options.swarselsystems.flakePath = mkOption {
type = types.str;
options.swarselsystems.user = lib.mkOption {
type = lib.types.str;
default = "swarsel";
};
options.swarselsystems.flakePath = lib.mkOption {
type = lib.types.str;
default = "";
};
options.swarselsystems.withHomeManager = mkOption {
type = types.bool;
options.swarselsystems.withHomeManager = lib.mkOption {
type = lib.types.bool;
default = true;
};
options.swarselsystems.isSwap = lib.mkOption {
type = lib.types.bool;
default = true;
};
options.swarselsystems.swapSize = lib.mkOption {
type = lib.types.str;
default = "8G";
};
options.swarselsystems.rootDisk = lib.mkOption {
type = lib.types.str;
default = "";
};
options.swarselsystems.isCrypted = lib.mkEnableOption "uses full disk encryption";
options.swarselsystems.isPublic = lib.mkEnableOption "is a public machine (no secrets)";
options.swarselsystems.initialSetup = lib.mkEnableOption "initial setup (no sops keys available)";

options.swarselsystems.isBtrfs = lib.mkEnableOption "use btrfs filesystem";
options.swarselsystems.isImpermanence = lib.mkEnableOption "use impermanence on this system";
}
#+end_src

***** Server

#+begin_src nix :tangle modules/nixos/server.nix
{ lib, ... }:
{
options.swarselsystems.server.enable = lib.mkEnableOption "is a server machine";
options.swarselsystems.server.kavita = lib.mkEnableOption "enable kavita on server";
options.swarselsystems.server.jellyfin = lib.mkEnableOption "enable jellyfin on server";
Expand Down Expand Up @@ -3661,36 +3682,6 @@ This section is for everything input-related on the NixOS side. At the moment, t
}
#+end_src

***** Impermanence
:PROPERTIES:
:CUSTOM_ID: h:e591075d-4a77-4add-bbc8-b711998fa97f
:END:

Option to enable impermanence configurations. This could also be done via optional imports, but impermanence is a "big enough" change to warrant a line in the machine =default.nix=.

#+begin_src nix :tangle modules/nixos/impermanence.nix
{ lib, ... }:

{
options.swarselsystems.impermanence = lib.mkEnableOption "use impermanence on this system";
}
#+end_src

***** Filesystem
:PROPERTIES:
:CUSTOM_ID: h:f77358ee-a80c-403a-be9d-04e7052bc556
:END:

This lets me quickly set flags for "special" file systems. These options mostly function in conjunction with other settings (for example, the =isBtrfs= function is mostly used for impermanence configuration).

#+begin_src nix :tangle modules/nixos/filesystem.nix
{ lib, ... }:

{
options.swarselsystems.isBtrfs = lib.mkEnableOption "use btrfs filesystem";
}
#+end_src

**** home-manager
:PROPERTIES:
:CUSTOM_ID: h:ced5841f-c088-4d88-b3a1-7d62aad8837b
Expand Down Expand Up @@ -5541,16 +5532,12 @@ Normally, doing that also resets the lecture that happens on the first use of =s
{ config, lib, ... }:
let
mkIfElse = p: yes: no: if p then yes else no;
mkIfElseList = p: yes: no: lib.mkMerge [
(lib.mkIf p yes)
(lib.mkIf (!p) no)
];
mapperTarget = mkIfElse config.swarselsystems.isCrypted "/dev/mapper/cryptroot" "/dev/disk/by-label/nixos";
in

{

security.sudo.extraConfig = lib.mkIf config.swarselsystems.impermanence ''
security.sudo.extraConfig = lib.mkIf config.swarselsystems.isImpermanence ''
# rollback results in sudo lectures after each reboot
Defaults lecture = never
'';
Expand All @@ -5561,12 +5548,12 @@ Normally, doing that also resets the lecture that happens on the first use of =s

boot.initrd.systemd.enable = true;

boot.initrd.systemd.services.rollback = lib.mkIf config.swarselsystems.impermanence {
boot.initrd.systemd.services.rollback = lib.mkIf config.swarselsystems.isImpermanence {
description = "Rollback BTRFS root subvolume to a pristine state";
wantedBy = [ "initrd.target" ];
# make sure it's done after encryption
# i.e. LUKS/TPM process
after = mkIfElseList config.swarselsystems.isCrypted [ "[email protected]" ] [ "dev-disk-by\\x2dlabel-nixos.device" ];
after = lib.swarselsystems.mkIfElseList config.swarselsystems.isCrypted [ "[email protected]" ] [ "dev-disk-by\\x2dlabel-nixos.device" ];
requires = lib.mkIf (!config.swarselsystems.isCrypted) [ "dev-disk-by\\x2dlabel-nixos.device" ];
# mount the root fs before clearing
before = [ "sysroot.mount" ];
Expand Down Expand Up @@ -5609,7 +5596,7 @@ Normally, doing that also resets the lecture that happens on the first use of =s
};


environment.persistence."/persist" = lib.mkIf config.swarselsystems.impermanence {
environment.persistence."/persist" = lib.mkIf config.swarselsystems.isImpermanence {
hideMounts = true;
directories =
[
Expand Down
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@
systemFunc = func;
in
systemFunc {
specialArgs = { inherit inputs outputs self; };
specialArgs = {
inherit inputs outputs self;
lib = lib.extend (_: _: { swarselsystems = import ./lib { inherit lib; }; });
};
modules = [ ./hosts/${if isNixos then "nixos" else "darwin"}/${host} ];
};
};
Expand Down
Loading

0 comments on commit 32e2467

Please sign in to comment.