From 721819ea5ced5c79466ffbfbc9beea0d9bddd5cb Mon Sep 17 00:00:00 2001 From: "A.Ottr" Date: Fri, 16 Aug 2024 18:41:21 +0200 Subject: [PATCH] migrate old config --- flake.nix | 57 ++++++++++++++------ home/ferret/default.nix | 13 +++++ home/otter/default.nix | 66 ++--------------------- lib/nixosSystem.nix | 42 +++++++++++++++ nixos/ferret/configuration.nix | 69 +++++++++++++++++++++++++ nixos/ferret/default.nix | 11 ++++ nixos/ferret/hardware-configuration.nix | 31 +++++++++++ nixos/ferret/media.nix | 47 +++++++++++++++++ 8 files changed, 257 insertions(+), 79 deletions(-) create mode 100644 home/ferret/default.nix create mode 100644 lib/nixosSystem.nix create mode 100644 nixos/ferret/configuration.nix create mode 100644 nixos/ferret/default.nix create mode 100644 nixos/ferret/hardware-configuration.nix create mode 100644 nixos/ferret/media.nix diff --git a/flake.nix b/flake.nix index b6be86f..4b69dac 100644 --- a/flake.nix +++ b/flake.nix @@ -11,23 +11,48 @@ }; }; - outputs = { nixpkgs, catppuccin, home-manager, ... }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in { - homeConfigurations."alex" = home-manager.lib.homeManagerConfiguration { - inherit pkgs; + outputs = inputs @ { nixpkgs, catppuccin, home-manager, ... }: + let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { - # Specify your home configuration modules here, for example, - # the path to your home.nix. - modules = [ - ./home/otter - catppuccin.homeManagerModules.catppuccin - ]; + # TODO optimize HM config (currently just otter / Framework) + homeConfigurations."alex" = home-manager.lib.homeManagerConfiguration { + inherit pkgs; - # Optionally use extraSpecialArgs - # to pass through arguments to home.nix - }; + # Specify your home configuration modules here, for example, + # the path to your home.nix. + modules = [ + ./home/otter + catppuccin.homeManagerModules.catppuccin + ]; + + # Optionally use extraSpecialArgs + # to pass through arguments to home.nix }; + + nixosConfiguration = let + username = "alex"; + #system = "x86_64-linux"; + nixosSystem = import ./lib/nixosSystem.nix; + home-module = import ./home/ferret; + nixos-modules = import ./nixos/ferret; + ferret_modules = { + inherit nixos-modules; + inherit home-module; + }; + args = { + inherit nixpkgs; + inherit home-manager; + inherit system; + specialArgs = { + inherit inputs; + inherit username; + }; + }; + in { + ferret = nixosSystem (ferret_modules // args); + }; + }; } diff --git a/home/ferret/default.nix b/home/ferret/default.nix new file mode 100644 index 0000000..ded0136 --- /dev/null +++ b/home/ferret/default.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + imports = [ + ../common/fish.nix + ]; + + home.username = "alex"; + home.homeDirectory = "/home/alex"; + home.stateVersion = "23.11"; # Please read the comment before changing. + + programs.home-manager.enable = true; +} diff --git a/home/otter/default.nix b/home/otter/default.nix index d925d92..200cf94 100644 --- a/home/otter/default.nix +++ b/home/otter/default.nix @@ -12,76 +12,16 @@ ../common/dev/blog.nix ]; - # Home Manager needs a bit of information about you and the paths it should - # manage. home.username = "alex"; home.homeDirectory = "/home/alex"; - - # 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 = "24.05"; # Please read the comment before changing. - # The home.packages option allows you to install Nix packages into your - # environment. - home.packages = [ - # # 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" ]; }) + home.packages = []; - # # 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.file = {}; - # 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/alex/etc/profile.d/hm-session-vars.sh - # - home.sessionVariables = { - # EDITOR = "emacs"; - }; + home.sessionVariables = {}; - # Let Home Manager install and manage itself. programs.home-manager.enable = true; } diff --git a/lib/nixosSystem.nix b/lib/nixosSystem.nix new file mode 100644 index 0000000..9fe3006 --- /dev/null +++ b/lib/nixosSystem.nix @@ -0,0 +1,42 @@ +{ + nixpkgs, + home-manager, + specialArgs, + home-module, + nixos-modules, + system +}: let + username = specialArgs.username; +in + nixpkgs.lib.nixosSystem { + inherit system specialArgs; + modules = [ + ({pkgs, config, ... }: { + config = { + nix.settings = { + # add binary caches + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + #"nixpkgs-wayland.cachix.org-1:3lwxaILxMRkVhehr5StQprHdEo4IrE8sRho9R9HOLYA=" + ]; + substituters = [ + "https://cache.nixos.org" + #"https://nixpkgs-wayland.cachix.org" + ]; + }; + + # use it as an overlay + #nixpkgs.overlays = [ specialArgs.inputs.nixpkgs-wayland.overlay ]; + }; + }) + nixos-modules + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + + home-manager.extraSpecialArgs = specialArgs; + home-manager.users."${username}" = home-module; + } + ]; + } \ No newline at end of file diff --git a/nixos/ferret/configuration.nix b/nixos/ferret/configuration.nix new file mode 100644 index 0000000..ea8a451 --- /dev/null +++ b/nixos/ferret/configuration.nix @@ -0,0 +1,69 @@ +{ pkgs, ... }: + +{ + imports = [ + ./hardware-configuration.nix + ]; + services.openssh = { + enable = true; + settings.PasswordAuthentication = true; + settings.X11Forwarding = true; + }; + + nix.settings.experimental-features = ["nix-command" "flakes" "repl-flake" "no-url-literals"]; + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "ferret"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Enable networking + networking.networkmanager.enable = true; + + # Set your time zone. + time.timeZone = "Europe/Paris"; + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + i18n.extraLocaleSettings = { + LC_ADDRESS = "fr_FR.UTF-8"; + LC_IDENTIFICATION = "fr_FR.UTF-8"; + LC_MEASUREMENT = "fr_FR.UTF-8"; + LC_MONETARY = "fr_FR.UTF-8"; + LC_NAME = "fr_FR.UTF-8"; + LC_NUMERIC = "fr_FR.UTF-8"; + LC_PAPER = "fr_FR.UTF-8"; + LC_TELEPHONE = "fr_FR.UTF-8"; + LC_TIME = "fr_FR.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + + sound.enable = false; + services.pipewire = { + enable = false; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.alex = { + isNormalUser = true; + description = "Alex"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + git + ]; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + environment.systemPackages = [ + pkgs.tailscales + ]; + services.tailscale = { + enable = true; + }; + + system.stateVersion = "23.11"; # NixOS Install State +} diff --git a/nixos/ferret/default.nix b/nixos/ferret/default.nix new file mode 100644 index 0000000..c04ad2d --- /dev/null +++ b/nixos/ferret/default.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: + +{ + imports = [ + ./configuration.nix + ./hardware-configuration.nix + ./media.nix + ]; + + security.polkit.enable = true; +} diff --git a/nixos/ferret/hardware-configuration.nix b/nixos/ferret/hardware-configuration.nix new file mode 100644 index 0000000..5371601 --- /dev/null +++ b/nixos/ferret/hardware-configuration.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, modulesPath, ... }: +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = []; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/6e990a23-01fe-40e4-adc2-063973263f95"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/0586-430E"; + fsType = "vfat"; + }; + + swapDevices = [{ device = "/dev/disk/by-uuid/d96908d3-b46e-40c2-a5e0-82b71196899c"; }]; + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + # for tailscale + networking.nameservers = [ "100.100.100.100" "1.1.1.1" "9.9.9.9" ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/nixos/ferret/media.nix b/nixos/ferret/media.nix new file mode 100644 index 0000000..b73db57 --- /dev/null +++ b/nixos/ferret/media.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: + +{ + # TODO create reverse proxy + + users.groups.media = { + gid = 976; + }; + users.users.media = { + group = "media"; + isSystemUser = true; + uid = 976; + }; + + services.jellyfin = { + enable = true; + openFirewall = true; + + user = "media"; + group = "media"; + }; + + # Retrieve Metadata and Subtitles for DVDs + services.sonarr = { + enable = true; + openFirewall = true; + + user = "media"; + group = "media"; + }; + + services.radarr = { + enable = true; + openFirewall = true; + + user = "media"; + group = "media"; + }; + + services.bazarr = { + enable = true; + openFirewall = true; + + user = "media"; + group = "media"; + }; +} \ No newline at end of file -- 2.51.2