diff --git a/flake.lock b/flake.lock index 5a02815..e2f8dc9 100644 --- a/flake.lock +++ b/flake.lock @@ -195,6 +195,26 @@ "type": "github" } }, + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716431128, + "narHash": "sha256-t3T8HlX3udO6f4ilLcN+j5eC3m2gqsouzSGiriKK6vk=", + "owner": "nix-community", + "repo": "disko", + "rev": "7ffc4354dfeb37c8c725ae1465f04a9b45ec8606", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -774,6 +794,7 @@ "root": { "inputs": { "agenix": "agenix", + "disko": "disko", "home-manager": "home-manager_2", "home-manager-unstable": "home-manager-unstable", "nix-colors": "nix-colors", diff --git a/flake.nix b/flake.nix index c5f417d..075fd1c 100644 --- a/flake.nix +++ b/flake.nix @@ -29,35 +29,41 @@ inputs.nixpkgs.follows = "nixpkgs-unstable"; }; stylix.url = "github:danth/stylix"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self, nur, nixpkgs, nixos-hardware, nixos-wsl, nixpkgs-unstable , agenix, home-manager, home-manager-unstable, nix-colors, nixos-cosmic - , nixvim, stylix }@inputs: + , nixvim, stylix, disko }@inputs: let inherit (self) outputs; system = "x86_64-linux"; # helper function to create a machine - mkHost = { modules, specialArgs ? { pkgsVersion = nixpkgs-unstable; } }: + mkHost = { modules, specialArgs ? { pkgsVersion = nixpkgs-unstable; } + , system ? "x86_64-linux", minimal ? false }: nixpkgs-unstable.lib.nixosSystem { inherit system; - modules = modules ++ [ - ./modules - ({ outputs, ... }: { - nixpkgs.overlays = with outputs.overlays; [ - additions - modifications - unstable-packages - nur.overlay - ]; - # stylix compains if image is not set... - stylix.autoEnable = false; - stylix.image = ./yuyukowallpaper1809.png; - }) - home-manager-unstable.nixosModules.home-manager - agenix.nixosModules.default - nixos-cosmic.nixosModules.default - stylix.nixosModules.stylix - ]; + modules = modules ++ [ ./modules agenix.nixosModules.default ] + ++ (if !minimal then [ + ({ outputs, ... }: { + nixpkgs.overlays = with outputs.overlays; [ + additions + modifications + unstable-packages + nur.overlay + ]; + # stylix compains if image is not set... + stylix.autoEnable = true; + stylix.image = ./yuyukowallpaper1809.png; + }) + home-manager-unstable.nixosModules.home-manager + nixos-cosmic.nixosModules.default + stylix.nixosModules.stylix + #todo: check how to actually do this + ./modules/graphical/stylix.nix + ./modules/graphical/cosmic.nix + ] else + [ ]); specialArgs = specialArgs // { inherit inputs outputs; }; }; in { @@ -132,6 +138,12 @@ nixos-wsl.nixosModules.wsl ]; }; + "adam-site" = mkHost { + minimal = true; + system = "aarch64-linux"; + modules = + [ disko.nixosModules.disko ./systems/adam-site/configuration.nix ]; + }; }; }; } diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index cfcffed..5ceddec 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -1,9 +1,9 @@ -{ pkgs, config, ...}: +{ pkgs, config, lib, ...}: { + imports = [ ./audio.nix ./code.nix - ./cosmic.nix ./emulators.nix ./gamemode.nix ./games.nix @@ -15,7 +15,8 @@ ./obs.nix ./openrgb.nix ./plasma.nix + #./stylix.nix + #./cosmic.nix ./shared.nix - ./stylix.nix ]; } diff --git a/modules/nix/settings.nix b/modules/nix/settings.nix index d35d426..3980e51 100644 --- a/modules/nix/settings.nix +++ b/modules/nix/settings.nix @@ -14,9 +14,9 @@ in nix.registry.nixpkgs.flake = pkgsVersion; nix.nixPath = ["nixpkgs=flake:nixpkgs"]; nixpkgs.config.allowUnfree = true; - home-manager.users.${config.mainUser.name}.home.sessionVariables = { - NIX_PATH = "nixpkgs=flake:nixpkgs$\{NIX_PATH:+:$NIX_PATH}"; - NIXPKGS_ALLOW_UNFREE = "1"; - }; + ##home-manager.users.${config.mainUser.name}.home.sessionVariables = { + ## NIX_PATH = "nixpkgs=flake:nixpkgs$\{NIX_PATH:+:$NIX_PATH}"; + ## NIXPKGS_ALLOW_UNFREE = "1"; + ##}; }; } diff --git a/systems/adam-site/configuration.nix b/systems/adam-site/configuration.nix new file mode 100644 index 0000000..fbfac1a --- /dev/null +++ b/systems/adam-site/configuration.nix @@ -0,0 +1,35 @@ +{ modulesPath, config, lib, pkgs, ... }: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (modulesPath + "/profiles/qemu-guest.nix") + ./disk-config.nix + ]; + boot.loader.grub = { + # no need to set devices, disko will add all devices that have a EF02 partition to the list already + # devices = [ ]; + efiSupport = true; + efiInstallAsRemovable = true; + }; + services.openssh.enable = true; + services.nginx.enable = true; + networking.firewall.allowedTCPPorts = [ 22 80 443 ]; + custom = { + nftables.enable = true; + nix = { + settings.enable = true; + }; + }; + + environment.systemPackages = map lib.lowPrio [ + pkgs.curl + pkgs.gitMinimal + ]; + + users.users.root.openssh.authorizedKeys.keys = [ + # change this to your ssh key + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFeP6qtVqE/gu72ZUZE8cdRi3INiUW9NqDR7SjXIzTw2" + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMypKJQvn68s8iNk9J9zghFlW4nrd03FwqfvGQ9sAmWojXe6pKrkat++8grIfB60aiIwNjHeXigVdZrpIb0QiR7+maPLPtxySTmgD7GeyAbwJrAymgKAzJcQvq5tKHtjH60KhLe4QzGXXpjoGIhl/8FhepRT6306JE8OfMwBUwOa3wcEdeJ7eK4JZdELCne3Gj16eWHy8iNIQswNtvJ70M7RACyDJARuazde3zFqkRYCP9Rqinegg/DVd+ykC2qHqM/yCersCOGn+I3hPCS1tz/AhDTQ7T9A7j5CLjv6ZbRS+B7a7u7z5qOAla468sELaiAEo2+fovlh8kib5zzWM2pK3rSEfUzFVGAAfHtrdR8pYynl3DBNC5XGzDT8xqa4B/qJIRoPmr8CMroLBOGGZQm9TJbmhfl8vT96RUwOA6qUmLQl6b0qJRRMkvlgCvKZyZ3d6pPfizQigTn1evBveqO9dgGcCAyAi0Ob6JZisTWUn5nAqe7CR1h2EKC0lqdCc=" + ]; + + system.stateVersion = "23.11"; +} diff --git a/systems/adam-site/disk-config.nix b/systems/adam-site/disk-config.nix new file mode 100644 index 0000000..d245ca6 --- /dev/null +++ b/systems/adam-site/disk-config.nix @@ -0,0 +1,56 @@ +# Example to create a bios compatible gpt partition +{ lib, ... }: +{ + disko.devices = { + disk.disk1 = { + device = lib.mkDefault "/dev/sda"; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + name = "root"; + size = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} diff --git a/systems/adam-site/flake.lock b/systems/adam-site/flake.lock new file mode 100644 index 0000000..d98283c --- /dev/null +++ b/systems/adam-site/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716431128, + "narHash": "sha256-t3T8HlX3udO6f4ilLcN+j5eC3m2gqsouzSGiriKK6vk=", + "owner": "nix-community", + "repo": "disko", + "rev": "7ffc4354dfeb37c8c725ae1465f04a9b45ec8606", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716451822, + "narHash": "sha256-0lT5RVelqN+dgXWWneXvV5ufSksW0r0TDQi8O6U2+o8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3305b2b25e4ae4baee872346eae133cf6f611783", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/systems/adam-site/flake.nix b/systems/adam-site/flake.nix new file mode 100644 index 0000000..68f97d7 --- /dev/null +++ b/systems/adam-site/flake.nix @@ -0,0 +1,26 @@ +{ + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.disko.url = "github:nix-community/disko"; + inputs.disko.inputs.nixpkgs.follows = "nixpkgs"; + + outputs = { nixpkgs, disko, ... }: + { + nixosConfigurations.hetzner-cloud = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + disko.nixosModules.disko + ./configuration.nix + ]; + }; + # tested with 2GB/2CPU droplet, 1GB droplets do not have enough RAM for kexec + nixosConfigurations.digitalocean = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + disko.nixosModules.disko + { disko.devices.disk.disk1.device = "/dev/vda"; } + ./configuration.nix + ]; + }; + + }; +}