commit e887d8bc7d3ea7b5c43be8f3c3ccdc8c04d2ba4b Author: Lander Van den Bulcke Date: Mon Aug 26 09:53:25 2024 +0000 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a806510 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# ---> Nix +# Ignore build outputs from performing a nix-build or `nix build` command +result +result-* + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..42b5a9a --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2024 landervdb + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5af4a71 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# nix-config + +My Nix config \ No newline at end of file diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..654eba2 --- /dev/null +++ b/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719827415, + "narHash": "sha256-pvh+1hStXXAZf0sZ1xIJbWGx4u+OGBC1rVx6Wsw0fBw=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "f2e3c19867262dbe84fdfab42467fc8dd83a2005", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.11", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1720535198, + "narHash": "sha256-zwVvxrdIzralnSbcpghA92tWu2DV2lwv89xZc8MTrbg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "205fd4226592cc83fd4c0885a3e4c9c400efabb5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..87e5d48 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "Your new nix config"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; + + # Home manager + home-manager.url = "github:nix-community/home-manager/release-23.11"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + in { + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + wodan = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs;}; + # > Our main nixos configuration file < + modules = [./nixos/configuration.nix]; + }; + }; + }; +} diff --git a/home-manager/git/default.nix b/home-manager/git/default.nix new file mode 100644 index 0000000..d2c72fa --- /dev/null +++ b/home-manager/git/default.nix @@ -0,0 +1,69 @@ +# adapted from https://pickard.cc/posts/git-identity-home-manager/ + +{ config, lib, pkgs, ...}: + +let + # put a shell script into the nix store + gitIdentity = + pkgs.writeShellScriptBin "git-identity" (builtins.readFile ./git-identity); +in { + # we will use the excellent fzf in our `git-identity` script, so let's make sure it's available + # let's add the gitIdentity script to the path as well + home.packages = with pkgs; [ + gitIdentity + fzf + ]; + + programs.git = { + enable = true; + package = pkgs.gitAndTools.gitFull; + + extraConfig = { + # extremely important, otherwise git will attempt to guess a default user identity. see `man git-config` for more details + user.useConfigOnly = true; + + # the `inuits` identity + user.inuits.name = "Lander Van den Bulcke"; + user.inuits.email = "landervdb@inuits.eu"; + + # the `olly` identity + user.olly.name = "Lander Van den Bulcke"; + user.olly.email = "landervdb@o11y.eu"; + + # the `paynovate` identity + user.paynovate.name = "Lander Van den Bulcke"; + user.paynovate.email = "lander.vandenbulcke@paynovate.com"; + + # the `personal` identity + user.personal.name = "Lander Van den Bulcke"; + user.personal.email = "landervandenbulcke@gmail.com"; + + # editor + core.editor = "vim"; + + # line up default branch with github/codeberg/forgejo + init.defaultBranch = "main"; + + # always rebase xx + pull.rebase = true; + + push.autoSetupRemote = true; + rebase.autosquash = true; + commit.verbose = true; + diff.algorithm = "histogram"; + transfer.fsckobjects = true; + fetch.fsckobjects = true; + receive.fsckObjects = true; + rerere.enabled = true; + + # sign your commits! + commit.gpgsign = true; + }; + # This is optional, as `git identity` will call the `git-identity` script by itself, however + # setting it up explicitly as an alias gives you autocomplete + aliases = { + identity = "! git-identity"; + id = "! git-identity"; + }; + }; +} diff --git a/home-manager/git/git-identity b/home-manager/git/git-identity new file mode 100644 index 0000000..8e1816a --- /dev/null +++ b/home-manager/git/git-identity @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# get each set of usernames from the git config +IDENTITIES=$(git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//') +# filter them with fzf +ID=$(echo "${IDENTITIES}" | fzf -e -1 +m -q "$1") +if ! git config --global --get-regexp "user.${ID}.name" > /dev/null; then + echo "Please use a valid git identity +Options:" + git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//' -e 's/^/\t/' + exit 1 +fi + +# set the id locally in each repo (eg in the repo's .git/config) +git config user.name "$(git config user.${ID}.name)" +git config user.email "$(git config user.${ID}.email)" diff --git a/home-manager/home.nix b/home-manager/home.nix new file mode 100644 index 0000000..5beab6c --- /dev/null +++ b/home-manager/home.nix @@ -0,0 +1,68 @@ +# This is your home-manager configuration file +# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix) +{ + inputs, + lib, + config, + pkgs, + ... +}: { + # You can import other home-manager modules here + imports = [ + # If you want to use home-manager modules from other flakes (such as nix-colors): + # inputs.nix-colors.homeManagerModule + + # You can also split up your configuration and import pieces of it here: + # ./nvim.nix + ./git + ]; + + nixpkgs = { + # You can add overlays here + overlays = [ + # If you want to use overlays exported from other flakes: + # neovim-nightly-overlay.overlays.default + + # Or define it inline, for example: + # (final: prev: { + # hi = final.hello.overrideAttrs (oldAttrs: { + # patches = [ ./change-hello-to-hi.patch ]; + # }); + # }) + ]; + # Configure your nixpkgs instance + config = { + # Disable if you don't want unfree packages + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = _: true; + }; + }; + + home = { + username = "lander"; + homeDirectory = "/home/lander"; + }; + + # Add stuff for your user as you see fit: + # programs.neovim.enable = true; + # home.packages = with pkgs; [ steam ]; + + # Enable home-manager and git + programs.home-manager.enable = true; + programs.git.enable = true; + + programs.neovim = { + enable = true; + vimAlias = true; + vimdiffAlias = true; + defaultEditor = false; + }; + + + # Nicely reload system units when changing configs + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "23.05"; +} diff --git a/nixos/configuration.nix b/nixos/configuration.nix new file mode 100644 index 0000000..ba40a88 --- /dev/null +++ b/nixos/configuration.nix @@ -0,0 +1,136 @@ +# 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, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ./home-manager.nix + ./yubikey-gpg.nix + ./virt.nix + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + boot.initrd.luks.devices."luks-ed2282ac-fd73-4d82-9224-b7596b5b7cac".device = "/dev/disk/by-uuid/ed2282ac-fd73-4d82-9224-b7596b5b7cac"; + networking.hostName = "wodan"; # 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/Brussels"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "nl_BE.UTF-8"; + LC_IDENTIFICATION = "nl_BE.UTF-8"; + LC_MEASUREMENT = "nl_BE.UTF-8"; + LC_MONETARY = "nl_BE.UTF-8"; + LC_NAME = "nl_BE.UTF-8"; + LC_NUMERIC = "nl_BE.UTF-8"; + LC_PAPER = "nl_BE.UTF-8"; + LC_TELEPHONE = "nl_BE.UTF-8"; + LC_TIME = "nl_BE.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.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. + hardware.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.lander = { + isNormalUser = true; + description = "Lander"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + # thunderbird + ]; + }; + + # 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 # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + ]; + + # 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; + + services.tailscale.enable = true; + + # 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 = "24.05"; # Did you read the comment? + +} diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix new file mode 100644 index 0000000..f2f8de6 --- /dev/null +++ b/nixos/hardware-configuration.nix @@ -0,0 +1,43 @@ +# 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 = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/1f43e0d1-65c6-4954-a943-968152e40a5e"; + fsType = "ext4"; + }; + + boot.initrd.luks.devices."luks-a9fe90af-2f6b-41ad-a086-d1b9df2db5d2".device = "/dev/disk/by-uuid/a9fe90af-2f6b-41ad-a086-d1b9df2db5d2"; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/0EB6-0E42"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/d7432008-bd3e-4bd5-b6d7-0fcd7df00c54"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/nixos/home-manager.nix b/nixos/home-manager.nix new file mode 100644 index 0000000..1c54254 --- /dev/null +++ b/nixos/home-manager.nix @@ -0,0 +1,12 @@ +{ inputs, outputs, ... }: { + imports = [ + inputs.home-manager.nixosModules.home-manager + ]; + + home-manager = { + extraSpecialArgs = { inherit inputs outputs; }; + users = { + lander = import ../home-manager/home.nix; + }; + }; +} diff --git a/nixos/virt.nix b/nixos/virt.nix new file mode 100644 index 0000000..22b200b --- /dev/null +++ b/nixos/virt.nix @@ -0,0 +1,31 @@ +{config, pkgs, ... }: + +{ + programs.dconf.enable = true; + + users.users.lander.extraGroups = [ "libvirtd" ]; + + environment.systemPackages = with pkgs; [ + virt-manager + virt-viewer + spice + spice-gtk + spice-protocol + win-virtio + win-spice + gnome.adwaita-icon-theme + ]; + + virtualisation = { + libvirtd = { + enable = true; + qemu = { + swtpm.enable = true; + ovmf.enable = true; + ovmf.packages = [ pkgs.OVMFFull.fd ]; + }; + }; + spiceUSBRedirection.enable = true; + }; + services.spice-vdagentd.enable = true; +} diff --git a/nixos/yubikey-gpg.nix b/nixos/yubikey-gpg.nix new file mode 100644 index 0000000..8bfbd5d --- /dev/null +++ b/nixos/yubikey-gpg.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: + +{ + programs.ssh.startAgent = false; + + services.pcscd.enable = true; + + programs.gnupg.agent = { + enable = true; + enableSSHSupport = true; + }; + + services.gnome.gnome-keyring.enable = lib.mkForce false; + + environment.systemPackages = with pkgs; [ + yubikey-personalization + ]; +}