Skip to content

Commit

Permalink
♻️ Refactor flake
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Leer <[email protected]>
  • Loading branch information
mahtaran committed May 3, 2024
1 parent 21b2bc0 commit 99a0293
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 71 deletions.
49 changes: 49 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Based on https://github.com/gitattributes/gitattributes

# Auto detect text files and perform LF normalization
* text=auto

# The above will handle all files NOT found below

# Tool configuration
## Git
.gitattributes text
.gitignore text

## Others
.editorconfig text
.env.example text

# Documents
## Plain text
*.md text

# Media
## Audio
*.flac binary
*.ogg binary

## Fonts
*.eot binary
*.ttf binary
*.woff binary

## Graphics
*.png binary
*.jpg binary
*.svg text

## Video
*.mkv binary
*.webm binary

# Data
*.json text
*.yaml text
*.toml text
secret/**/*.yaml text diff=sopsdiffer

# Code
*.ps1 text eol=crlf
*.sh text eol=lf
*.py text
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Based on https://github.com/github/gitignore

# Secrets
settings.nix
105 changes: 42 additions & 63 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,73 +45,52 @@
};
};

outputs =
inputs@{ ... }:
let
systemSettings = {
architecture = "x86_64-linux";
secureBoot = false;
timezone = "Europe/Amsterdam";
defaultLocale = "en_GB.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "nl_NL.UTF-8";
LC_IDENTIFICATION = "nl_NL.UTF-8";
LC_MEASUREMENT = "nl_NL.UTF-8";
LC_MONETARY = "nl_NL.UTF-8";
LC_NAME = "nl_NL.UTF-8";
LC_NUMERIC = "nl_NL.UTF-8";
LC_PAPER = "nl_NL.UTF-8";
LC_TELEPHONE = "nl_NL.UTF-8";
LC_TIME = "nl_NL.UTF-8";
outputs = inputs@{ ... }:
let
settings = import ./settings.nix;
alejandra = inputs.alejandra.defaultPackage.${settings.system.architecture};
in {
formatter.${settings.system.architecture} = alejandra;

nixosConfigurations = {
${settings.system.name} = inputs.nixpkgs.lib.nixosSystem {
system = settings.system.architecture;
specialArgs = {
inherit inputs;
inherit settings;
};
};
userSettings = {
username = "mahtaran";
name = "Luka";
email = "[email protected]";
editor = "nano";
};
in
{
formatter.${systemSettings.architecture} = inputs.alejandra.defaultPackage.${systemSettings.architecture};
modules = [
{ nix.settings.experimental-features = ["nix-command" "flakes"]; }
inputs.disko.nixosModules.disko
inputs.lanzaboote.nixosModules.lanzaboote
inputs.sops-nix.nixosModules.sops
inputs.impermanence.nixosModules.impermanence
inputs.nur.nixosModules.nur

nixosConfigurations = {
feanor = inputs.nixpkgs.lib.nixosSystem rec {
system = systemSettings.architecture;
specialArgs = {
inherit inputs;
inherit systemSettings userSettings;
};
modules = [
inputs.disko.nixosModules.disko
./module/disko.nix
inputs.lanzaboote.nixosModules.lanzaboote
inputs.sops-nix.nixosModules.sops
inputs.impermanence.nixosModules.impermanence
inputs.nur.nixosModules.nur
./host/feanor/configuration.nix
{ environment.systemPackages = [ inputs.alejandra.defaultPackage.${system} ]; }
inputs.home-manager.nixosModules.home-manager
(
{ ... }:
{
home-manager = {
extraSpecialArgs = {
inherit inputs;
inherit systemSettings userSettings;
};
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ inputs.nur.hmModules.nur ];
./host/${settings.system.name}/configuration.nix
{ environment.systemPackages = [ alejandra ]; }

inputs.home-manager.nixosModules.home-manager
(
{ ... }:
{
home-manager = {
extraSpecialArgs = {
inherit inputs;
inherit settings;
};
useGlobalPkgs = true;
useUserPackages = true;
sharedModules = [ inputs.nur.hmModules.nur ];

users = {
${userSettings.username} = import ./user/${userSettings.username}/home.nix;
};
users = {
${settings.user.name} = import ./user/${settings.user.name}/home.nix;
};
}
)
];
};
};
}
)
];
};
};
};
}
10 changes: 4 additions & 6 deletions host/feanor/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
lib,
pkgs,
inputs,
systemSettings,
userSettings,
settings,
...
}: {
imports = [
./hardware-configuration.nix
../../module/disko.nix
../../module/nixos/btrfs.nix
../../module/nixos/manage-script.nix
../../module/nixos/optimise.nix
../../module/fingerprint.nix
../../module/hyprland.nix
];

nix.settings.experimental-features = ["nix-command" "flakes"];

sops = {
age = {
keyFile = "/persist/home/mahtaran/.config/sops/age/keys.txt";
Expand All @@ -34,7 +32,7 @@
};

boot = lib.mkMerge [
(lib.mkIf (systemSettings.secureBoot) {
(lib.mkIf (settings.system.secureBoot) {
loader.systemd-boot.enable = lib.mkForce false;
lanzaboote = {
enable = true;
Expand All @@ -51,7 +49,7 @@
};
})

(lib.mkIf (!systemSettings.secureBoot) {
(lib.mkIf (!settings.system.secureBoot) {
loader.systemd-boot.enable = true;
})

Expand Down
26 changes: 26 additions & 0 deletions settings.example.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{ ... }: {
system = {
name = "feanor";
architecture = "x86_64-linux";
secureBoot = false;
timezone = "Europe/Amsterdam";
defaultLocale = "en_GB.UTF-8";
extraLocaleSettings = {
LC_ADDRESS = "nl_NL.UTF-8";
LC_IDENTIFICATION = "nl_NL.UTF-8";
LC_MEASUREMENT = "nl_NL.UTF-8";
LC_MONETARY = "nl_NL.UTF-8";
LC_NAME = "nl_NL.UTF-8";
LC_NUMERIC = "nl_NL.UTF-8";
LC_PAPER = "nl_NL.UTF-8";
LC_TELEPHONE = "nl_NL.UTF-8";
LC_TIME = "nl_NL.UTF-8";
};
};
user = {
name = "mahtaran";
display = "Luka";
email = "[email protected]";
editor = "nano";
};
}
3 changes: 1 addition & 2 deletions user/mahtaran/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
config,
pkgs,
inputs,
systemSettings,
userSettings,
settings,
...
}: {
imports = [
Expand Down

0 comments on commit 99a0293

Please sign in to comment.