From 8ecabce74cf2bf8d2918e07a40fc875b100e9b30 Mon Sep 17 00:00:00 2001 From: cubernetes Date: Sun, 24 May 2026 21:57:01 +0200 Subject: [PATCH] Initial commit --- flake.lock | 70 ++++++++++++++ flake.nix | 36 ++++++++ hosts/fw/configuration.nix | 137 ++++++++++++++++++++++++++++ hosts/fw/hardware-configuration.nix | 35 +++++++ hosts/fw/home.nix | 82 +++++++++++++++++ modules/home-manager/bash.nix | 12 +++ modules/home-manager/git.nix | 19 ++++ modules/home-manager/ssh.nix | 19 ++++ 8 files changed, 410 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/fw/configuration.nix create mode 100644 hosts/fw/hardware-configuration.nix create mode 100644 hosts/fw/home.nix create mode 100644 modules/home-manager/bash.nix create mode 100644 modules/home-manager/git.nix create mode 100644 modules/home-manager/ssh.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..90c9f3c --- /dev/null +++ b/flake.lock @@ -0,0 +1,70 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1779506708, + "narHash": "sha256-QOD/CNm196nCJRheux/URi4/HE66fthdOMqCJoPP1Y0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "3ee51fbdac8c8bdfe1e7e1fcaba6520a563f394f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-25.11", + "repo": "home-manager", + "type": "github" + } + }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1779604987, + "narHash": "sha256-ZQ5z+fVhxYKtIFwtqGp5O0PD84BM1riASvqDaN5Xs+s=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "8fba98c80b48fa013820e0163c5096922fea4ddd", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1779467186, + "narHash": "sha256-nOesoDCiXcUftqbRBMz9tt4blI5PvljMWbm3kuCA+0s=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b77b3de8775677f84492abe84635f87b0e153f0f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-25.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-index-database": "nix-index-database", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..00e0fd2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "NixOs Config Flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11"; + + home-manager = { + url = "github:nix-community/home-manager/release-25.11"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + + nix-index-database = { + url = "github:nix-community/nix-index-database"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + home-manager, + nix-index-database, + ... + }@inputs: + { + + nixosConfigurations.fw = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs; }; + modules = [ + ./hosts/fw/configuration.nix + home-manager.nixosModules.home-manager + nix-index-database.nixosModules.default + ]; + }; + }; +} diff --git a/hosts/fw/configuration.nix b/hosts/fw/configuration.nix new file mode 100644 index 0000000..50d684d --- /dev/null +++ b/hosts/fw/configuration.nix @@ -0,0 +1,137 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, inputs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + boot.initrd.luks.devices."luks-1dfcf980-6806-4f69-bd86-ee87c904c04b".device = "/dev/disk/by-uuid/1dfcf980-6806-4f69-bd86-ee87c904c04b"; + networking.hostName = "fw"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "de_DE.UTF-8"; + LC_IDENTIFICATION = "de_DE.UTF-8"; + LC_MEASUREMENT = "de_DE.UTF-8"; + LC_MONETARY = "de_DE.UTF-8"; + LC_NAME = "de_DE.UTF-8"; + LC_NUMERIC = "de_DE.UTF-8"; + LC_PAPER = "de_DE.UTF-8"; + LC_TELEPHONE = "de_DE.UTF-8"; + LC_TIME = "de_DE.UTF-8"; + }; + + # Enable the X11 windowing system. + # You can disable this if you're only using the Wayland session. + services.xserver.enable = true; + + # Enable the KDE Plasma Desktop Environment. + services.displayManager.sddm.enable = true; + services.desktopManager.plasma6.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.tsi = { + isNormalUser = true; + description = "tsi"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; []; + }; + + # Install firefox. + programs.firefox.enable = true; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [vim]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "25.11"; # Did you read the comment? + + nix.settings.experimental-features = ["nix-command" "flakes"]; + + programs.nix-index-database.comma.enable = true; + + home-manager = { + extraSpecialArgs = { inherit inputs; }; + users = { + "tsi" = import ./home.nix; + }; + }; +} diff --git a/hosts/fw/hardware-configuration.nix b/hosts/fw/hardware-configuration.nix new file mode 100644 index 0000000..5a64eb1 --- /dev/null +++ b/hosts/fw/hardware-configuration.nix @@ -0,0 +1,35 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/mapper/luks-9b0c979a-d40b-490c-9eff-616f1c9b7c5d"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-9b0c979a-d40b-490c-9eff-616f1c9b7c5d".device = "/dev/disk/by-uuid/9b0c979a-d40b-490c-9eff-616f1c9b7c5d"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/A7E8-C6F3"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/mapper/luks-1dfcf980-6806-4f69-bd86-ee87c904c04b"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/fw/home.nix b/hosts/fw/home.nix new file mode 100644 index 0000000..7d47336 --- /dev/null +++ b/hosts/fw/home.nix @@ -0,0 +1,82 @@ +{ config, pkgs, ... }: + +{ + # Home Manager needs a bit of information about you and the paths it should + # manage. + home.username = "tsi"; + home.homeDirectory = "/home/tsi"; + + imports = [ + ../../modules/home-manager/git.nix + ../../modules/home-manager/ssh.nix + ../../modules/home-manager/bash.nix + ]; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "25.11"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # pkgs.hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (pkgs.writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/tsi/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/modules/home-manager/bash.nix b/modules/home-manager/bash.nix new file mode 100644 index 0000000..133add4 --- /dev/null +++ b/modules/home-manager/bash.nix @@ -0,0 +1,12 @@ +{ ... }: + +{ + programs.bash = { + enable = true; + shellAliases = { + rb = "sudo nixos-rebuild switch --flake /etc/nixos#fw"; + nx = "vim ~/nixos-config/hosts/fw/configuration.nix"; + hm = "vim ~/nixos-config/hosts/fw/home.nix"; + }; + }; +} diff --git a/modules/home-manager/git.nix b/modules/home-manager/git.nix new file mode 100644 index 0000000..495eeed --- /dev/null +++ b/modules/home-manager/git.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + programs.git = { + enable = true; + settings = { + user = { + name = "cubernetes"; + email = "timo42@proton.me"; + }; + init = { + defaultBranch = "main"; + }; + core = { + editor = "vim"; + }; + }; + }; +} diff --git a/modules/home-manager/ssh.nix b/modules/home-manager/ssh.nix new file mode 100644 index 0000000..c115c9a --- /dev/null +++ b/modules/home-manager/ssh.nix @@ -0,0 +1,19 @@ +{ ... }: + +{ + services.ssh-agent.enable = true; + + home.sessionVariables = { + SSH_AUTH_SOCK = "$XDG_RUNTIME_DIR/ssh-agent"; + }; + + programs.ssh = { + enable = true; + enableDefaultConfig = false; + matchBlocks = { + "*" = { + identitiesOnly = true; + }; + }; + }; +}