From 97d648948f26e71bc03ea80d6b550da1ce67bac0 Mon Sep 17 00:00:00 2001 From: Lyes Saadi Date: Wed, 24 Apr 2024 20:55:22 +0200 Subject: [PATCH] Switching to flakes and adding home-manager --- configuration.nix | 3 +-- flake.nix | 22 ++++++++++++++++++++++ hardware/x1-extreme-gen4.nix | 33 ++++++++++++++++++++++++++++----- packages.nix | 4 ++-- system.nix | 15 ++++++++++----- up.sh | 10 +++++----- user/home.nix | 25 +++++++++++++++++++++++++ user/packages.nix | 24 +++++++++++++++++++----- user/user.nix | 14 ++++++++++++-- 9 files changed, 124 insertions(+), 26 deletions(-) create mode 100644 flake.nix create mode 100644 user/home.nix diff --git a/configuration.nix b/configuration.nix index 2a6e860..2f8a7a3 100644 --- a/configuration.nix +++ b/configuration.nix @@ -6,10 +6,9 @@ ./hardware-configuration.nix ./packages.nix ./system.nix - ./hardware.nix # Set in the up.sh script among the files in hardware/ + # ./hardware.nix # Set in the up.sh script among the files in hardware/ ./networking.nix ./user/user.nix - ]; nixpkgs.config.allowUnfree = true; diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..049df81 --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + description = "NixOS Configuration"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + }; + + outputs = { self, nixpkgs, nixos-hardware, ... }@attrs: { + nixosConfigurations.lyes-nix = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = attrs; + modules = [ + ./configuration.nix + ./hardware/x1-extreme-gen4.nix + nixos-hardware.nixosModules.lenovo-thinkpad-x1-extreme-gen4 + ]; + }; + }; +} diff --git a/hardware/x1-extreme-gen4.nix b/hardware/x1-extreme-gen4.nix index e51b28b..b9a2d59 100644 --- a/hardware/x1-extreme-gen4.nix +++ b/hardware/x1-extreme-gen4.nix @@ -1,11 +1,31 @@ { config, ... }: { - imports = - [ - - ]; + # Optimisation + # nixpkgs.hostPlatform = { + # gcc.arch = "tigerlake"; + # gcc.tune = "tigerlake"; + # system = "x86_64-linux"; + # }; + + nix.settings.system-features = [ "gccarch-tigerlake" "nixos-test" "benchmark" "big-parallel" "kvm" ]; + + # Increasing the limit of files to help with compilation + security.pam.loginLimits = [{ + domain = "*"; + type = "soft"; + item = "nofile"; + value = "8192"; + }]; + + # Disabling failing test + # nixpkgs.overlays = [ (final: prev: { + # orc = prev.orc.overrideAttrs (_: { doCheck = false; }); + # }) ]; + + # NVidia + services.xserver.videoDrivers = [ "nvidia" ]; hardware.opengl = { @@ -28,4 +48,7 @@ # Optionally, you may need to select the appropriate driver version for your specific GPU package = config.boot.kernelPackages.nvidiaPackages.stable; }; -} \ No newline at end of file + + # For containers + virtualisation.containers.cdi.dynamic.nvidia.enable = true; +} diff --git a/packages.nix b/packages.nix index 0ea7be2..3f0b2b5 100644 --- a/packages.nix +++ b/packages.nix @@ -1,4 +1,3 @@ - { pkgs, ... }: { @@ -15,6 +14,7 @@ man-pages-posix python3 any-nix-shell + libcgroup # Virtualization qemu @@ -42,4 +42,4 @@ enable = true; enableSSHSupport = true; }; -} \ No newline at end of file +} diff --git a/system.nix b/system.nix index b237897..b9c5ae0 100644 --- a/system.nix +++ b/system.nix @@ -38,15 +38,15 @@ useXkbConfig = true; }; - services.xserver.layout = "fr"; - services.xserver.xkbVariant = "oss"; + services.xserver.xkb.layout = "fr"; + services.xserver.xkb.variant = "oss"; services.xserver.libinput.enable = true; # Printing services.printing.enable = true; services.avahi.enable = true; - services.avahi.nssmdns = true; + services.avahi.nssmdns4 = true; services.avahi.openFirewall = true; # Shell @@ -56,6 +56,12 @@ ''; environment.shells = with pkgs; [ fish ]; + # # Environment Variables + # environment.sessionVariables = { + # ELECTRON_OZONE_PLATFORM_HINT = "wayland"; + # GTK_USE_PORTAL = "1"; + # }; + # Graphics services.xserver.enable = true; programs.xwayland.enable = true; @@ -97,6 +103,5 @@ dockerCompat = true; defaultNetwork.settings.dns_enabled = true; extraPackages = [ pkgs.zfs ]; - enableNvidia = true; }; -} \ No newline at end of file +} diff --git a/up.sh b/up.sh index 5529935..afaf45b 100755 --- a/up.sh +++ b/up.sh @@ -2,11 +2,11 @@ rm *.qcow2 result 2> /dev/null -if [ -n "$1" ]; then - echo "Changing hardware" - cp hardware/"$1".nix hardware.nix - exit 0 -fi +# if [ -n "$1" ]; then +# echo "Changing hardware" +# cp hardware/"$1".nix hardware.nix +# exit 0 +# fi if [ "$EUID" -ne 0 ]; then echo "Please run as root" diff --git a/user/home.nix b/user/home.nix new file mode 100644 index 0000000..d003b51 --- /dev/null +++ b/user/home.nix @@ -0,0 +1,25 @@ +{ ... }: + +{ + # Git config + programs.git = { + enable = true; + userName = "Lyes Saadi"; + userEmail = "dev@lyes.eu"; + signing = { + key = "17418538BAA17767"; + signByDefault = true; + }; + extraConfig = { + code.editor = "nvim"; + merge.tool = "nvim"; + color.ui = true; + init.defaultBranch = "main"; + includeIf = { + "gitdir:~/Documents/fedpkg/" = { + path = "~/Documents/fedpkg/.gitconfig_include"; + }; + }; + }; + }; +} diff --git a/user/packages.nix b/user/packages.nix index ff1c632..9d99320 100644 --- a/user/packages.nix +++ b/user/packages.nix @@ -1,7 +1,18 @@ { pkgs, ... }: let - unstable = import { config = { allowUnfree = true; }; }; + tex = (pkgs.texlive.combine { inherit (pkgs.texlive) + scheme-medium + lettre + wallpaper + lastpage + hyphenat + moresize + fontawesome5 + montserrat + titlesec + ly1; + }); in { users.users.lyes.packages = with pkgs; [ # Software @@ -13,10 +24,10 @@ in { syncplay gnome.gnome-tweaks gnome-extension-manager - unstable.protonmail-bridge-gui + protonmail-bridge-gui # Games - citra-canary + # citra-canary steam minecraft vvvvvv @@ -37,16 +48,19 @@ in { # Programming git + vscode ocaml ledit nodejs + nil # Containers toolbox distrobox # Note taking - texlive.combined.scheme-medium + setzer + tex pandoc # Multimedia @@ -54,4 +68,4 @@ in { pulseaudio libopus ]; -} \ No newline at end of file +} diff --git a/user/user.nix b/user/user.nix index af2dc2f..374f5b4 100644 --- a/user/user.nix +++ b/user/user.nix @@ -1,9 +1,10 @@ -{ pkgs, ... }: +{ pkgs, home-manager, ... }: { imports = [ ./packages.nix + home-manager.nixosModules.default ]; users.users.lyes = { @@ -16,7 +17,16 @@ }; home-manager.useUserPackages = true; + home-manager.useGlobalPkgs = true; home-manager.users.lyes = { pkgs, ... }: { + imports = + [ + ./home.nix + ]; + + home.username = "lyes"; + home.homeDirectory = "/home/lyes"; + home.stateVersion = "22.11"; }; -} \ No newline at end of file +}