From 0e66175517790d1375a7dd9b291227de131dec27 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Fri, 2 Sep 2022 01:25:42 +0200 Subject: [PATCH 1/9] chore: remove unused packages and aliases --- home.nix | 8 -------- 1 file changed, 8 deletions(-) diff --git a/home.nix b/home.nix index 952cb4a..e7723c5 100644 --- a/home.nix +++ b/home.nix @@ -41,7 +41,6 @@ network = "traefik" latest.pavucontrol latest.bluezFull - latest.niv latest.sakura latest.fasd @@ -338,7 +337,6 @@ source <(kubectl completion zsh) dcr = "docker-compose run --rm"; dcrm = "docker-compose rm -fsv"; copy = "xclip -selection c"; - deploy = "docker run -it --rm -v ~/.ssh:/root/.ssh -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v $(pwd):/source neolao/capistrano:3.4.0 bash"; bepo = "setxkbmap -layout fr -variant bepo"; fr = "setxkbmap -layout fr -variant oss"; @@ -353,12 +351,6 @@ source <(kubectl completion zsh) g = "git"; tg = "tig --all"; tgs = "tig status"; - tgl = "tig status"; - tgb = "tig blame -C"; - - # for some reasons `light -k -S 100` does not work for me… TODO find why, and uninstall upower - klon = "dbus-send --system --type=method_call --dest=\"org.freedesktop.UPower\" \"/org/freedesktop/UPower/KbdBacklight\" \"org.freedesktop.UPower.KbdBacklight.SetBrightness\" int32:100"; - kloff = "light -k -S 0"; }; }; From b011686173645029c130a9c792f11593c55f1e8c Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Fri, 2 Sep 2022 01:26:16 +0200 Subject: [PATCH 2/9] feat(framework): initial Framework setup --- home.nix | 2 +- nixos/configuration.nix | 203 +++++++++++++++++----------------------- nixos/framework.nix | 79 ++++++++++++++++ 3 files changed, 166 insertions(+), 118 deletions(-) create mode 100644 nixos/framework.nix diff --git a/home.nix b/home.nix index e7723c5..6ae12e9 100644 --- a/home.nix +++ b/home.nix @@ -4,7 +4,7 @@ let latest = import {}; in { - home.stateVersion = "18.09"; + home.stateVersion = "22.05"; home.file.".config/traefik/traefik.toml".text = '' logLevel = "INFO" defaultEntryPoints = ["http", "https"] diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 9214cd4..4150a01 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -6,88 +6,104 @@ { imports = - [ + [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./framework.nix + ]; - # Use the GRUB 2 boot loader. - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - # boot.loader.grub.efiSupport = true; - # boot.loader.grub.efiInstallAsRemovable = true; - # boot.loader.efi.efiSysMountPoint = "/boot/efi"; - # Define on which hard drive you want to install Grub. - boot.loader.grub.device = "/dev/nvme0n1"; # or "nodev" for efi only - # Perso only ? (and comment grub.enable / version above) - # boot.loader.systemd-boot.enable = true; - # boot.loader.efi.canTouchEfiVariables = true; - - boot.cleanTmpDir = true; + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; networking.hostName = "pierre"; # Define your hostname. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.networkmanager.enable = true; # Gnome is forcing us to use networkManager https://nixos.org/nixos/manual/index.html#sec-networkmanager + + # 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; networking.extraHosts = " "; - - hardware.bluetooth.enable = true; - # see https://nixos.wiki/wiki/Bluetooth#Enabling_A2DP_Sink - hardware.bluetooth.settings = { - General = { - Enable = "Source,Sink,Media,Socket"; - MultiProfile = "multiple"; - AutoEnable = true; - }; - }; - - hardware.trackpoint.enable = true; - hardware.trackpoint.emulateWheel = true; - hardware.trackpoint.speed = 250; - hardware.trackpoint.sensitivity = 150; - - # Select internationalisation properties. - console.keyMap = "fr-bepo"; - # Set your time zone. time.timeZone = "Europe/Paris"; + # Select internationalisation properties. + i18n.defaultLocale = "en_US.utf8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "fr_FR.utf8"; + LC_IDENTIFICATION = "fr_FR.utf8"; + LC_MEASUREMENT = "fr_FR.utf8"; + LC_MONETARY = "fr_FR.utf8"; + LC_NAME = "fr_FR.utf8"; + LC_NUMERIC = "fr_FR.utf8"; + LC_PAPER = "fr_FR.utf8"; + LC_TELEPHONE = "fr_FR.utf8"; + LC_TIME = "fr_FR.utf8"; + }; + + # Configure keymap in X11 + services.xserver = { + enable = true; + layout = "fr"; + xkbVariant = "bepo"; + + displayManager = { + defaultSession = "none+i3"; + }; + windowManager = { + i3 = { + enable = true; + }; + }; + + # videoDrivers = [ "intel" "nvidia" ]; + }; + + # Configure console keymap + console.keyMap = "fr"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.pierre = { + isNormalUser = true; + description = "Pierre"; + extraGroups = [ "networkmanager" "wheel" "audio" "docker" "video" ]; + shell = pkgs.zsh; + packages = with pkgs; []; + }; + home-manager.users.pierre = import /home/pierre/dotfiles/home.nix; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + # List packages installed in system profile. To search, run: # $ nix search wget environment.systemPackages = with pkgs; [ thunderbolt - wpa_supplicant - #wpa_supplicant_gui - gitAndTools.gitFull - docker - firefox - unbound - # Yubikey - libu2f-host - yubikey-manager - yubikey-personalization-gui - pcsclite + # Basics + docker + gitAndTools.gitFull + vim # Sound blueman bluez-tools ]; - - nix.settings.auto-optimise-store = true; - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 30d"; - }; - - # Specific configuration - environment.pathsToLink = [ "/share/zsh" ]; + virtualisation.docker.enable = true; # 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; }; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; programs.zsh.enable = true; # see https://github.com/NixOS/nixpkgs/issues/20548#issuecomment-261965667 programs.light.enable = true; @@ -99,68 +115,21 @@ services.gnome.gnome-keyring.enable = true; # see https://nixos.wiki/wiki/Visual_Studio_Code#Error_after_Sign_On services.blueman.enable = true; - services.clamav.daemon.enable = true; - services.clamav.updater.enable = true; + # Enable the OpenSSH daemon. + # services.openssh.enable = true; - virtualisation.docker.enable = true; + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; - # Doc: https://nixos.org/manual/nixos/stable/index.html#sec-firewall - networking.firewall.enable = true; - - # Enable CUPS to print documents. - nixpkgs.config.allowUnfree = true; - services.printing.enable = true; - services.printing.drivers = [ - pkgs.hplip - pkgs.gutenprint - ]; - - # Enable sound. - sound.enable = true; - hardware.pulseaudio = { - enable = true; - - # NixOS allows either a lightweight build (default) or full build of PulseAudio to be installed. - # Only the full build has Bluetooth support, so it must be selected here. - package = pkgs.pulseaudioFull; - - # see https://nixos.wiki/wiki/Bluetooth#Managing_audio_devices - extraConfig = " - load-module module-switch-on-connect - "; - }; - - # Enable the X11 windowing system. - services.xserver.enable = true; - services.xserver.layout = "fr"; - services.xserver.xkbVariant = "bepo"; - # services.xserver.xkbOptions = "eurosign:e"; - - # Enable touchpad support. - services.xserver.libinput.enable = true; - - services.xserver.videoDriver = "modesetting"; # to prevent "xrandr: Configure crtc 1 failed" issues - services.xserver.displayManager.gdm.wayland = false; - services.xserver.windowManager.i3.enable = true; - - # See https://nixos.wiki/wiki/Yubikey - services.udev.packages = [ pkgs.yubikey-personalization pkgs.libu2f-host ]; - services.pcscd.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.pierre = { - isNormalUser = true; - uid = 1000; - home = "/home/pierre"; - shell = pkgs.zsh; - extraGroups = [ "audio" "wheel" "networkmanager" "docker" "video" ]; - }; - - system.autoUpgrade.enable = true; - # This value determines the NixOS release with which your system is to be - # compatible, in order to avoid breaking some software such as database - # servers. You should change this only after NixOS release notes say you - # should. - system.stateVersion = "18.09"; # Did you read the comment? + # 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 = "22.05"; # Did you read the comment? } diff --git a/nixos/framework.nix b/nixos/framework.nix new file mode 100644 index 0000000..65dde9c --- /dev/null +++ b/nixos/framework.nix @@ -0,0 +1,79 @@ +# +# NixOS Configuration for Framework Laptop +# Source: https://gist.github.com/digitalknk/ee0379c1cd4597463c31a323ea5882a5 +# Alt: https://github.com/NixOS/nixos-hardware/blob/master/framework/default.nix +# Alt: https://github.com/DAlperin/dotfiles/blob/main/machines/spaceship/default.nix +# Doc: https://wiki.archlinux.org/title/Framework_Laptop +# + +{ config, lib, pkgs, modulesPath, ... }: + +{ + boot.kernelParams = [ + "mem_sleep_default=deep" + "nvme.noacpi=1" # power consumption. See https://github.com/NixOS/nixos-hardware/blob/12620020f76b1b5d2b0e6fbbda831ed4f5fe56e1/framework/default.nix#L12 + "module_blacklist=hid_sensor_hub" # brightness keys. See https://dov.dev/blog/nixos-on-the-framework-12th-gen + ]; + + # TODO Understand why it is needed and uncomment it! + # boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_latest.override { + # argsOverride = rec { + # src = pkgs.fetchurl { + # url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; + # sha256 = "1j0lnrsj5y2bsmmym8pjc5wk4wb11y336zr9gad1nmxcr0rwvz9j"; + # }; + # version = "5.15.1"; + # modDirVersion = "5.15.1"; + # }; + # }); + + powerManagement = { + enable = true; + powertop.enable = true; + # TODO Not sure what it does: the default detection uses "powersave" + # cpuFreqGovernor = lib.mkDefault "ondemand"; + }; + + hardware.bluetooth.enable = true; + + # Enable thermal data + services.thermald.enable = true; + + # TODO Enable fingerprint support + # services.fprintd.enable = true; + + # TODO make second screen work!! ¯\_(ツ)_/¯ + # $ nix-shell -p glxinfo --run glxinfo | egrep "OpenGL vendor|OpenGL renderer" + # OpenGL vendor string: Mesa/X.org + # OpenGL renderer string: llvmpipe (LLVM 13.0.1, 256 bits) + hardware.video.hidpi.enable = lib.mkDefault true; # https://github.com/kvark/dotfiles/blob/master/nix/hardware-configuration.nix#L41 + hardware.opengl.enable = true; + hardware.opengl.extraPackages = with pkgs; [ + mesa_drivers + vaapiIntel + vaapiVdpau + libvdpau-va-gl + intel-media-driver + ]; + + # Bring in some audio + security.rtkit.enable = true; # rtkit is optional but recommended + 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; + + # Backlight (see https://wiki.archlinux.org/title/Backlight#xbacklight_returns_:_No_outputs_have_backlight_property) + hardware.acpilight.enable = true; +} \ No newline at end of file From c8ea58bd994063622f6816ff53a8e42fdd3e0722 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Fri, 2 Sep 2022 02:15:07 +0200 Subject: [PATCH 3/9] remove home-manager url from home.nix --- home.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/home.nix b/home.nix index 6ae12e9..fea56d6 100644 --- a/home.nix +++ b/home.nix @@ -150,11 +150,6 @@ network = "traefik" services.gpg-agent.enable = true; services.blueman-applet.enable = true; - programs.home-manager = { - enable = true; - path = https://github.com/nix-community/home-manager/archive/master.tar.gz; - }; - programs.rofi = { enable = true; plugins = [ latest.rofi-calc latest.rofi-emoji ]; From cfc7255631d2b67138cedc72870599859f04932b Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Fri, 2 Sep 2022 02:36:05 +0200 Subject: [PATCH 4/9] refactor: move dotfiles into files + symlink from home-manager --- .i3status.conf => files/.i3status.conf | 0 files/traefik.toml | 17 +++++++++++++++++ home.nix | 20 ++------------------ 3 files changed, 19 insertions(+), 18 deletions(-) rename .i3status.conf => files/.i3status.conf (100%) create mode 100644 files/traefik.toml diff --git a/.i3status.conf b/files/.i3status.conf similarity index 100% rename from .i3status.conf rename to files/.i3status.conf diff --git a/files/traefik.toml b/files/traefik.toml new file mode 100644 index 0000000..a932137 --- /dev/null +++ b/files/traefik.toml @@ -0,0 +1,17 @@ +logLevel = "INFO" +defaultEntryPoints = ["http", "https"] + +[web] +address = ":8080" + +# [entryPoints] +# [entryPoints.http] +# address = ":80" +# [entryPoints.https] +# address = ":443" +# [entryPoints.https.tls] + +[docker] +domain = "test" +watch = true +network = "traefik" \ No newline at end of file diff --git a/home.nix b/home.nix index fea56d6..c97d62d 100644 --- a/home.nix +++ b/home.nix @@ -5,25 +5,9 @@ let in { home.stateVersion = "22.05"; - home.file.".config/traefik/traefik.toml".text = '' -logLevel = "INFO" -defaultEntryPoints = ["http", "https"] -[web] -address = ":8080" - -# [entryPoints] -# [entryPoints.http] -# address = ":80" -# [entryPoints.https] -# address = ":443" -# [entryPoints.https.tls] - -[docker] -domain = "test" -watch = true -network = "traefik" - ''; + home.file.".i3status.conf".source = ./files/.i3status.conf; + home.file.".config/traefik/traefik.toml".source = ./files/traefik.toml; home.packages = with pkgs; [ latest.wget From 6c062c2cdff3df3396de4dd8d1dd4eb18012998e Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sat, 3 Sep 2022 05:06:04 +0200 Subject: [PATCH 5/9] fix(framework): ensure displays work properly on unstable channels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to benefit from latest software versions with a screen that works :) … it requires a more recent kernel version ¯\_(ツ)_/¯ --- nixos/configuration.nix | 2 -- nixos/framework.nix | 18 +++--------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 4150a01..01d3152 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -61,8 +61,6 @@ enable = true; }; }; - - # videoDrivers = [ "intel" "nvidia" ]; }; # Configure console keymap diff --git a/nixos/framework.nix b/nixos/framework.nix index 65dde9c..f0ea11f 100644 --- a/nixos/framework.nix +++ b/nixos/framework.nix @@ -15,17 +15,8 @@ "module_blacklist=hid_sensor_hub" # brightness keys. See https://dov.dev/blog/nixos-on-the-framework-12th-gen ]; - # TODO Understand why it is needed and uncomment it! - # boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_latest.override { - # argsOverride = rec { - # src = pkgs.fetchurl { - # url = "mirror://kernel/linux/kernel/v5.x/linux-${version}.tar.xz"; - # sha256 = "1j0lnrsj5y2bsmmym8pjc5wk4wb11y336zr9gad1nmxcr0rwvz9j"; - # }; - # version = "5.15.1"; - # modDirVersion = "5.15.1"; - # }; - # }); + # Use latest kernel version because on 5.15 screen is not detected properly (and external monitor doesn't work either) + boot.kernelPackages = pkgs.linuxPackages_5_18; # see https://github.com/NixOS/nixpkgs/issues/183955#issuecomment-1210468614 powerManagement = { enable = true; @@ -42,10 +33,7 @@ # TODO Enable fingerprint support # services.fprintd.enable = true; - # TODO make second screen work!! ¯\_(ツ)_/¯ - # $ nix-shell -p glxinfo --run glxinfo | egrep "OpenGL vendor|OpenGL renderer" - # OpenGL vendor string: Mesa/X.org - # OpenGL renderer string: llvmpipe (LLVM 13.0.1, 256 bits) + # Display thins like a boss hardware.video.hidpi.enable = lib.mkDefault true; # https://github.com/kvark/dotfiles/blob/master/nix/hardware-configuration.nix#L41 hardware.opengl.enable = true; hardware.opengl.extraPackages = with pkgs; [ From d83cdb025581477c5f267a79cf2e4186311fe6d3 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sat, 3 Sep 2022 05:13:00 +0200 Subject: [PATCH 6/9] feat(screen): ensure screens are automatically setup on startup + FC bg --- home.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home.nix b/home.nix index c97d62d..24ff2cf 100644 --- a/home.nix +++ b/home.nix @@ -220,6 +220,9 @@ in { command = "copyq"; notification = false; } { command = "numlockx on"; notification = false; } # turn verr num on + { command = "autorandr -c"; notification = false; } + { command = "feh --bg-scale /home/pierre/Documents/Graphisme/fc-bg-light-black.png"; notification = false; } + # docker run -d --net traefik --ip 172.10.0.10 --restart always -v /var/run/docker.sock:/var/run/docker.sock:ro --name traefik -p 80:80 -p 8080:8080 traefik:2.4.9 --api.insecure=true --providers.docker { command = "docker start traefik"; notification = false; } ]; From b1e097feeaeeb9792d0d689eb56d3cace3410c69 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sat, 3 Sep 2022 05:51:52 +0200 Subject: [PATCH 7/9] feat(framework): tweak HiDPi settings for a nicer display --- nixos/framework.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nixos/framework.nix b/nixos/framework.nix index f0ea11f..f1bc243 100644 --- a/nixos/framework.nix +++ b/nixos/framework.nix @@ -33,8 +33,8 @@ # TODO Enable fingerprint support # services.fprintd.enable = true; - # Display thins like a boss - hardware.video.hidpi.enable = lib.mkDefault true; # https://github.com/kvark/dotfiles/blob/master/nix/hardware-configuration.nix#L41 + # Display things like a boss + ## Make it work hardware.opengl.enable = true; hardware.opengl.extraPackages = with pkgs; [ mesa_drivers @@ -43,6 +43,15 @@ libvdpau-va-gl intel-media-driver ]; + ## Make it nice (https://nixos.wiki/wiki/Xorg && https://wiki.archlinux.org/title/Framework_Laptop#HiDPI_settings) + # https://github.com/kvark/dotfiles/blob/master/nix/hardware-configuration.nix#L41 + hardware.video.hidpi.enable = lib.mkDefault true; + services.xserver.dpi = 130; + environment.variables = { + GDK_SCALE = "1.5"; + GDK_DPI_SCALE = "0.77"; # 1/1.3 + _JAVA_OPTIONS = "-Dsun.java2d.uiScale=1.5"; + }; # Bring in some audio security.rtkit.enable = true; # rtkit is optional but recommended From 632df0cab4f875b6237344827ef0e4a10cd81077 Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sat, 3 Sep 2022 06:22:17 +0200 Subject: [PATCH 8/9] feat(auth): enable fingerprint detection for auth --- home.nix | 1 + nixos/framework.nix | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/home.nix b/home.nix index 24ff2cf..c671766 100644 --- a/home.nix +++ b/home.nix @@ -58,6 +58,7 @@ in latest.yubico-pam latest.yubikey-manager latest.pam_u2f + latest.polkit_gnome # fun fact: https://gitlab.gnome.org/GNOME/gdm/-/issues/613 latest.arandr latest.feh diff --git a/nixos/framework.nix b/nixos/framework.nix index f1bc243..bff8e7c 100644 --- a/nixos/framework.nix +++ b/nixos/framework.nix @@ -30,8 +30,9 @@ # Enable thermal data services.thermald.enable = true; - # TODO Enable fingerprint support - # services.fprintd.enable = true; + # Enable fingerprint support + # see https://wiki.archlinux.org/title/fprint for usage + services.fprintd.enable = true; # Display things like a boss ## Make it work From b6aa157e095411aa4dc7fb6c758990d53333ab4d Mon Sep 17 00:00:00 2001 From: Pierre Martin Date: Sat, 3 Sep 2022 06:43:55 +0200 Subject: [PATCH 9/9] fix(audio): install pulseaudio for pactl binary (used for volume buttons) --- home.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/home.nix b/home.nix index c671766..c0730d8 100644 --- a/home.nix +++ b/home.nix @@ -23,6 +23,7 @@ in latest.ngrok latest.openssl + latest.pulseaudioFull latest.pavucontrol latest.bluezFull