diff --git a/flake.nix b/flake.nix index 84ced73..4333e54 100644 --- a/flake.nix +++ b/flake.nix @@ -5,30 +5,38 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05"; nixpkgs.follows = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + disko.url = "github:nix-community/disko"; }; - outputs = { self, nixpkgs, flake-utils, home-manager, ... }: + outputs = { self, nixpkgs, nixpkgs-stable, flake-utils, home-manager, disko, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs { + mkHost = { hostname, isInstall ? false }: nixpkgs.lib.nixosSystem { inherit system; - config.allowUnfree = true; + specialArgs = { + inherit system; + pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; + isInstall = isInstall; + }; + modules = + [ + ./hosts/${hostname}/configuration.nix + ./modules/common.nix + ./modules/users/alisceon.nix + home-manager.nixosModules.home-manager + ] + ++ nixpkgs.lib.optional isInstall disko.nixosModules.disko + ++ nixpkgs.lib.optional isInstall ./hosts/${hostname}/disko.nix; }; in { - nixosConfigurations.laptop = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = { - inherit system pkgs; - }; - modules = [ - ./hosts/electra/configuration.nix - ./modules/common.nix - ./modules/users/alisceon.nix - home-manager.nixosModules.home-manager - ]; + nixosConfigurations = { + laptop = mkHost { hostname = "electra"; }; + laptop-install = mkHost { hostname = "electra"; isInstall = true; }; }; }); } diff --git a/hosts/electra/configuration.nix b/hosts/electra/configuration.nix index eb65f4f..93694fe 100644 --- a/hosts/electra/configuration.nix +++ b/hosts/electra/configuration.nix @@ -5,12 +5,23 @@ [ ./hardware-configuration.nix ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + boot.initrd.luks.devices."cryptroot".device = "/dev/disk/by-partlabel/luks"; + + boot.resumeDevice = "/dev/vg0/swap"; + + time.timeZone = "Europe/Stockholm"; + i18n.defaultLocale = "sv_SE.UTF-8"; + + services.openssh.enable = true; + + fileSystems."/".options = [ "compress=zstd" ]; networking.hostName = "electra"; networking.networkmanager.enable = true; - time.timeZone = "UTC"; - i18n.defaultLocale = "en_US.UTF-8"; services.xserver = { enable = true; diff --git a/hosts/electra/disko.nix b/hosts/electra/disko.nix new file mode 100644 index 0000000..682561b --- /dev/null +++ b/hosts/electra/disko.nix @@ -0,0 +1,52 @@ +{ + device = "/dev/nvme0n1"; + + content = { + type = "gpt"; + partitions = { + boot = { + size = "512M"; + type = "EF00"; # EFI system partition + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + + luks = { + size = "100%"; + content = { + type = "luks"; + name = "cryptroot"; + settings.allowDiscards = true; + content = { + type = "lvm_pv"; + vg = "vg0"; + }; + }; + }; + }; + }; + + swap = { + size = "32G"; # Adjust to your RAM size + content = { + type = "swap"; + resumeDevice = true; + }; + }; + + lvm_vgs.vg0 = { + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "btrfs"; + mountpoint = "/"; + }; + }; + }; + }; +}