❄️ Nix configurations

migrate old config

+257 -79
+41 -16
flake.nix
··· 11 11 }; 12 12 }; 13 13 14 - outputs = { nixpkgs, catppuccin, home-manager, ... }: 15 - let 16 - system = "x86_64-linux"; 17 - pkgs = nixpkgs.legacyPackages.${system}; 18 - in { 19 - homeConfigurations."alex" = home-manager.lib.homeManagerConfiguration { 20 - inherit pkgs; 14 + outputs = inputs @ { nixpkgs, catppuccin, home-manager, ... }: 15 + let 16 + system = "x86_64-linux"; 17 + pkgs = nixpkgs.legacyPackages.${system}; 18 + in { 19 + 20 + # TODO optimize HM config (currently just otter / Framework) 21 + homeConfigurations."alex" = home-manager.lib.homeManagerConfiguration { 22 + inherit pkgs; 23 + 24 + # Specify your home configuration modules here, for example, 25 + # the path to your home.nix. 26 + modules = [ 27 + ./home/otter 28 + catppuccin.homeManagerModules.catppuccin 29 + ]; 21 30 22 - # Specify your home configuration modules here, for example, 23 - # the path to your home.nix. 24 - modules = [ 25 - ./home/otter 26 - catppuccin.homeManagerModules.catppuccin 27 - ]; 31 + # Optionally use extraSpecialArgs 32 + # to pass through arguments to home.nix 33 + }; 28 34 29 - # Optionally use extraSpecialArgs 30 - # to pass through arguments to home.nix 35 + nixosConfiguration = let 36 + username = "alex"; 37 + #system = "x86_64-linux"; 38 + nixosSystem = import ./lib/nixosSystem.nix; 39 + home-module = import ./home/ferret; 40 + nixos-modules = import ./nixos/ferret; 41 + ferret_modules = { 42 + inherit nixos-modules; 43 + inherit home-module; 31 44 }; 32 - }; 45 + args = { 46 + inherit nixpkgs; 47 + inherit home-manager; 48 + inherit system; 49 + specialArgs = { 50 + inherit inputs; 51 + inherit username; 52 + }; 53 + }; 54 + in { 55 + ferret = nixosSystem (ferret_modules // args); 56 + }; 57 + }; 33 58 }
+13
home/ferret/default.nix
··· 1 + { config, pkgs, ... }: 2 + 3 + { 4 + imports = [ 5 + ../common/fish.nix 6 + ]; 7 + 8 + home.username = "alex"; 9 + home.homeDirectory = "/home/alex"; 10 + home.stateVersion = "23.11"; # Please read the comment before changing. 11 + 12 + programs.home-manager.enable = true; 13 + }
+3 -63
home/otter/default.nix
··· 12 12 ../common/dev/blog.nix 13 13 ]; 14 14 15 - # Home Manager needs a bit of information about you and the paths it should 16 - # manage. 17 15 home.username = "alex"; 18 16 home.homeDirectory = "/home/alex"; 19 - 20 - # This value determines the Home Manager release that your configuration is 21 - # compatible with. This helps avoid breakage when a new Home Manager release 22 - # introduces backwards incompatible changes. 23 - # 24 - # You should not change this value, even if you update Home Manager. If you do 25 - # want to update the value, then make sure to first check the Home Manager 26 - # release notes. 27 17 home.stateVersion = "24.05"; # Please read the comment before changing. 28 18 29 - # The home.packages option allows you to install Nix packages into your 30 - # environment. 31 - home.packages = [ 32 - # # Adds the 'hello' command to your environment. It prints a friendly 33 - # # "Hello, world!" when run. 34 - # pkgs.hello 19 + home.packages = []; 35 20 36 - # # It is sometimes useful to fine-tune packages, for example, by applying 37 - # # overrides. You can do that directly here, just don't forget the 38 - # # parentheses. Maybe you want to install Nerd Fonts with a limited number of 39 - # # fonts? 40 - # (pkgs.nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) 41 - 42 - # # You can also create simple shell scripts directly inside your 43 - # # configuration. For example, this adds a command 'my-hello' to your 44 - # # environment: 45 - # (pkgs.writeShellScriptBin "my-hello" '' 46 - # echo "Hello, ${config.home.username}!" 47 - # '') 48 - ]; 49 - 50 - # Home Manager is pretty good at managing dotfiles. The primary way to manage 51 21 # plain files is through 'home.file'. 52 - home.file = { 53 - # # Building this configuration will create a copy of 'dotfiles/screenrc' in 54 - # # the Nix store. Activating the configuration will then make '~/.screenrc' a 55 - # # symlink to the Nix store copy. 56 - # ".screenrc".source = dotfiles/screenrc; 22 + home.file = {}; 57 23 58 - # # You can also set the file content immediately. 59 - # ".gradle/gradle.properties".text = '' 60 - # org.gradle.console=verbose 61 - # org.gradle.daemon.idletimeout=3600000 62 - # ''; 63 - }; 24 + home.sessionVariables = {}; 64 25 65 - # Home Manager can also manage your environment variables through 66 - # 'home.sessionVariables'. These will be explicitly sourced when using a 67 - # shell provided by Home Manager. If you don't want to manage your shell 68 - # through Home Manager then you have to manually source 'hm-session-vars.sh' 69 - # located at either 70 - # 71 - # ~/.nix-profile/etc/profile.d/hm-session-vars.sh 72 - # 73 - # or 74 - # 75 - # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh 76 - # 77 - # or 78 - # 79 - # /etc/profiles/per-user/alex/etc/profile.d/hm-session-vars.sh 80 - # 81 - home.sessionVariables = { 82 - # EDITOR = "emacs"; 83 - }; 84 - 85 - # Let Home Manager install and manage itself. 86 26 programs.home-manager.enable = true; 87 27 }
+42
lib/nixosSystem.nix
··· 1 + { 2 + nixpkgs, 3 + home-manager, 4 + specialArgs, 5 + home-module, 6 + nixos-modules, 7 + system 8 + }: let 9 + username = specialArgs.username; 10 + in 11 + nixpkgs.lib.nixosSystem { 12 + inherit system specialArgs; 13 + modules = [ 14 + ({pkgs, config, ... }: { 15 + config = { 16 + nix.settings = { 17 + # add binary caches 18 + trusted-public-keys = [ 19 + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" 20 + #"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" 21 + ]; 22 + substituters = [ 23 + "https://cache.nixos.org" 24 + #"https://nixpkgs-wayland.cachix.org" 25 + ]; 26 + }; 27 + 28 + # use it as an overlay 29 + #nixpkgs.overlays = [ specialArgs.inputs.nixpkgs-wayland.overlay ]; 30 + }; 31 + }) 32 + nixos-modules 33 + home-manager.nixosModules.home-manager 34 + { 35 + home-manager.useGlobalPkgs = true; 36 + home-manager.useUserPackages = true; 37 + 38 + home-manager.extraSpecialArgs = specialArgs; 39 + home-manager.users."${username}" = home-module; 40 + } 41 + ]; 42 + }
+69
nixos/ferret/configuration.nix
··· 1 + { pkgs, ... }: 2 + 3 + { 4 + imports = [ 5 + ./hardware-configuration.nix 6 + ]; 7 + services.openssh = { 8 + enable = true; 9 + settings.PasswordAuthentication = true; 10 + settings.X11Forwarding = true; 11 + }; 12 + 13 + nix.settings.experimental-features = ["nix-command" "flakes" "repl-flake" "no-url-literals"]; 14 + # Bootloader. 15 + boot.loader.systemd-boot.enable = true; 16 + boot.loader.efi.canTouchEfiVariables = true; 17 + 18 + networking.hostName = "ferret"; # Define your hostname. 19 + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. 20 + 21 + # Enable networking 22 + networking.networkmanager.enable = true; 23 + 24 + # Set your time zone. 25 + time.timeZone = "Europe/Paris"; 26 + # Select internationalisation properties. 27 + i18n.defaultLocale = "en_US.UTF-8"; 28 + i18n.extraLocaleSettings = { 29 + LC_ADDRESS = "fr_FR.UTF-8"; 30 + LC_IDENTIFICATION = "fr_FR.UTF-8"; 31 + LC_MEASUREMENT = "fr_FR.UTF-8"; 32 + LC_MONETARY = "fr_FR.UTF-8"; 33 + LC_NAME = "fr_FR.UTF-8"; 34 + LC_NUMERIC = "fr_FR.UTF-8"; 35 + LC_PAPER = "fr_FR.UTF-8"; 36 + LC_TELEPHONE = "fr_FR.UTF-8"; 37 + LC_TIME = "fr_FR.UTF-8"; 38 + }; 39 + 40 + # Enable the X11 windowing system. 41 + services.xserver.enable = true; 42 + 43 + 44 + sound.enable = false; 45 + services.pipewire = { 46 + enable = false; 47 + }; 48 + 49 + # Define a user account. Don't forget to set a password with ‘passwd’. 50 + users.users.alex = { 51 + isNormalUser = true; 52 + description = "Alex"; 53 + extraGroups = [ "networkmanager" "wheel" ]; 54 + packages = with pkgs; [ 55 + git 56 + ]; 57 + }; 58 + 59 + # Allow unfree packages 60 + nixpkgs.config.allowUnfree = true; 61 + environment.systemPackages = [ 62 + pkgs.tailscales 63 + ]; 64 + services.tailscale = { 65 + enable = true; 66 + }; 67 + 68 + system.stateVersion = "23.11"; # NixOS Install State 69 + }
+11
nixos/ferret/default.nix
··· 1 + { pkgs, ... }: 2 + 3 + { 4 + imports = [ 5 + ./configuration.nix 6 + ./hardware-configuration.nix 7 + ./media.nix 8 + ]; 9 + 10 + security.polkit.enable = true; 11 + }
+31
nixos/ferret/hardware-configuration.nix
··· 1 + { config, lib, pkgs, modulesPath, ... }: 2 + { 3 + imports = [ 4 + (modulesPath + "/installer/scan/not-detected.nix") 5 + ]; 6 + 7 + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; 8 + boot.initrd.kernelModules = [ "dm-snapshot" ]; 9 + boot.kernelModules = [ "kvm-amd" ]; 10 + boot.extraModulePackages = []; 11 + 12 + fileSystems."/" = 13 + { device = "/dev/disk/by-uuid/6e990a23-01fe-40e4-adc2-063973263f95"; 14 + fsType = "ext4"; 15 + }; 16 + 17 + fileSystems."/boot" = 18 + { device = "/dev/disk/by-uuid/0586-430E"; 19 + fsType = "vfat"; 20 + }; 21 + 22 + swapDevices = [{ device = "/dev/disk/by-uuid/d96908d3-b46e-40c2-a5e0-82b71196899c"; }]; 23 + networking.useDHCP = lib.mkDefault true; 24 + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; 25 + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; 26 + 27 + # for tailscale 28 + networking.nameservers = [ "100.100.100.100" "1.1.1.1" "9.9.9.9" ]; 29 + 30 + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; 31 + }
+47
nixos/ferret/media.nix
··· 1 + { pkgs, ... }: 2 + 3 + { 4 + # TODO create reverse proxy 5 + 6 + users.groups.media = { 7 + gid = 976; 8 + }; 9 + users.users.media = { 10 + group = "media"; 11 + isSystemUser = true; 12 + uid = 976; 13 + }; 14 + 15 + services.jellyfin = { 16 + enable = true; 17 + openFirewall = true; 18 + 19 + user = "media"; 20 + group = "media"; 21 + }; 22 + 23 + # Retrieve Metadata and Subtitles for DVDs 24 + services.sonarr = { 25 + enable = true; 26 + openFirewall = true; 27 + 28 + user = "media"; 29 + group = "media"; 30 + }; 31 + 32 + services.radarr = { 33 + enable = true; 34 + openFirewall = true; 35 + 36 + user = "media"; 37 + group = "media"; 38 + }; 39 + 40 + services.bazarr = { 41 + enable = true; 42 + openFirewall = true; 43 + 44 + user = "media"; 45 + group = "media"; 46 + }; 47 + }