Skip to content

Commit

Permalink
Extract desktop specific NixOS config (#788)
Browse files Browse the repository at this point in the history
Preparation for GH-527
Part of GH-777

Fixes GH-680 and closes GH-742
  • Loading branch information
kachick committed Sep 16, 2024
1 parent 89d5b73 commit 9c5496a
Show file tree
Hide file tree
Showing 12 changed files with 352 additions and 362 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ nix flake show 'github:kachick/dotfiles' --json | jq '.nixosConfigurations | key

Candidates
- `user@linux-cli` # Used in container
- `kachick@linux-gui`

### Podman on Ubuntu

Expand Down
40 changes: 3 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
nixosConfigurations =
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
edge-pkgs = import edge-nixpkgs {
inherit system;
config = {
Expand All @@ -158,22 +157,6 @@
homemade-pkgs = homemade-packages.${system};
shared = {
inherit system;
modules = [
./nixos/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "backup";
# FIXME: Apply gnome.nix in #680
users.kachick = import ./home-manager/kachick.nix;
extraSpecialArgs = {
inherit homemade-pkgs edge-pkgs;
};
};
}
];
specialArgs = {
inherit
inputs
Expand All @@ -185,15 +168,9 @@
};
in
{
"moss" = nixpkgs.lib.nixosSystem (
shared // { modules = shared.modules ++ [ ./nixos/hosts/moss ]; }
);

"algae" = nixpkgs.lib.nixosSystem (
shared // { modules = shared.modules ++ [ ./nixos/hosts/algae ]; }
);

"wsl" = nixpkgs.lib.nixosSystem (shared // { modules = shared.modules ++ [ ./nixos/hosts/wsl ]; });
"moss" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/moss ]; });
"algae" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/algae ]; });
"wsl" = nixpkgs.lib.nixosSystem (shared // { modules = [ ./nixos/hosts/wsl ]; });
};

homeConfigurations =
Expand Down Expand Up @@ -223,17 +200,6 @@
};
in
{
"kachick@linux-gui" = home-manager.lib.homeManagerConfiguration (
x86-Linux
// {
modules = [
./home-manager/kachick.nix
./home-manager/systemd.nix
./home-manager/gnome.nix
];
}
);

"kachick@wsl" = home-manager.lib.homeManagerConfiguration (
x86-Linux
// {
Expand Down
190 changes: 27 additions & 163 deletions nixos/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,10 @@
lib,
...
}:
let
# https://github.com/NixOS/nixpkgs/issues/309662#issuecomment-2155122284
zed-fhs = pkgs.buildFHSUserEnv {
name = "zed";
targetPkgs = pkgs: [
# version in nixos-24.05 does not enable IME
edge-pkgs.zed-editor
];
runScript = "zed";
meta.mainProgram = "zed";
};
in
{
imports = [
./modules/cloudflare-warp.nix
(import ./font.nix { inherit pkgs homemade-pkgs; })
(import ./console.nix { inherit homemade-pkgs; })
(import ./language.nix { inherit config pkgs; })
];

nix.settings.experimental-features = [
Expand Down Expand Up @@ -63,25 +49,18 @@ in
};
};

# Set your time zone.
# TODO: Reconsider to set UTC for servers
time.timeZone = "Asia/Tokyo";

# Allow unfree packages
# Be careful to deploy containers if true, and it may take longtime in CI for non binary caches
nixpkgs.config.allowUnfree = true;

environment.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
SSH_ASKPASS_REQUIRE = "prefer";
NIXOS_OZONE_WL = "1";

# Avoiding hidden or unstable mouse cursors when using Alacritty/Wezterm on Wayland
#
# https://github.com/NixOS/nixpkgs/issues/22652
# https://github.com/alacritty/alacritty/issues/6703#issuecomment-2222503206
XCURSOR_THEME = "Adwaita";
};

# TODO: Reconsider to drop this
services.packagekit = {
enable = true;
};
Expand All @@ -91,7 +70,6 @@ in

hardware.bluetooth.enable = true; # enables support for Bluetooth
hardware.bluetooth.powerOnBoot = true; # powers up the default Bluetooth controller on boot
services.blueman.enable = true;

# Enable sound with pipewire.
sound.enable = true;
Expand All @@ -116,51 +94,21 @@ in
package = edge-pkgs.cloudflare-warp;
};

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users = {
kachick = {
isNormalUser = true;
description = "An admin";
extraGroups = [
"networkmanager"
"wheel"
"input" # For finger print in GDM
];
packages = [
# Don't install spotify, it does not activate IME and no binary cache with the unfree license.
# Use Web Player or PWA
];
};
};

environment.variables = {
# Don't set *IM_MODULE in KDE: https://discuss.kde.org/t/kde-plasma-wayland/9014
# QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";

EDITOR = lib.getExe pkgs.helix;
SYSTEMD_EDITOR = lib.getExe pkgs.helix;
VISUAL = "${lib.getExe zed-fhs} --wait";
};

# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages =
with pkgs;
[
(with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
helix
micro
zed-fhs
lapce # IME is not working on Windows, but stable even around IME on Wayland than vscode

usbutils # `lsusb` to get IDs

skk-dicts
skktools

alacritty

wget
curl
git
Expand All @@ -172,10 +120,6 @@ in
ripgrep
dig

# 3rd-party bitwarden helper, because of official cli does not have many core features
# Use latest because of nixos-24.05 distributing version has a crucial bug: https://github.com/quexten/goldwarden/issues/190
edge-pkgs.goldwarden

# Clipboard
#
# Don't use clipcat, copyq for wayland problem
Expand All @@ -184,108 +128,19 @@ in
#
# So use a clipboard gnome extension

# https://github.com/NixOS/nixpkgs/issues/33282
xdg-user-dirs

# Use stable packages even for GUI apps, because of using home-manager stable channel

firefox

# Don't use unstable channel. It frequently backported to stable channel
# - https://github.com/NixOS/nixpkgs/commits/nixos-24.05/pkgs/applications/networking/instant-messengers/signal-desktop/signal-desktop.nix
(signal-desktop.overrideAttrs (prev: {
preFixup =
prev.preFixup
+ ''
gappsWrapperArgs+=(
--add-flags "--enable-features=UseOzonePlatform"
--add-flags "--ozone-platform=wayland"
--add-flags "--enable-wayland-ime"
--add-flags "--disable-features=WaylandFractionalScaleV1"
)
'';
}))

podman-tui
docker-compose

chawan

gnome.dconf-editor

# https://github.com/NixOS/nixpkgs/issues/174353 - Super + / runs launcher by default
pop-launcher

nordic

## Unfree packages

# TODO: Consider using vscodium again
# TODO: Consider to drop the unuseful vscode until fixed the Wayland problems
# Don't use unstable channel. It frequently backported to stable channel
# - https://github.com/NixOS/nixpkgs/commits/nixos-24.05/pkgs/applications/editors/vscode/vscode.nix
(vscode.override (prev: {
# https://wiki.archlinux.org/title/Wayland#Electron
# https://github.com/NixOS/nixpkgs/blob/3f8b7310913d9e4805b7e20b2beabb27e333b31f/pkgs/applications/editors/vscode/generic.nix#L207-L214
commandLineArgs = (prev.commandLineArgs or [ ]) ++ [
"--enable-features=UseOzonePlatform"
"--ozone-platform=wayland"
"--enable-wayland-ime"
# https://github.com/microsoft/vscode/issues/192590#issuecomment-1731312805
# This bug appeared only when using GNOME, not in KDE
"--disable-features=WaylandFractionalScaleV1"
];
}))

# Don't use unstable channel. It frequently backported to stable channel
# - https://github.com/NixOS/nixpkgs/commits/nixos-24.05/pkgs/by-name/go/google-chrome/package.nix
# - Actually unstable is/was broken. See GH-776
#
# if you changed hostname and chrome doesn't run, see https://askubuntu.com/questions/476918/google-chrome-wont-start-after-changing-hostname
# `rm -rf ~/.config/google-chrome/Singleton*`
(google-chrome.override (prev: {
# https://wiki.archlinux.org/title/Chromium#Native_Wayland_support
# Similar as https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/chromium.nix
commandLineArgs = (prev.commandLineArgs or [ ]) ++ [
"--ozone-platform=wayland"
"--ozone-platform-hint=auto"
"--enable-wayland-ime"
];
}))
]
++ (with pkgs.gnomeExtensions; [
appindicator

# Should be changed from default CSS to another to avoid https://github.com/pop-os/shell/issues/132
# https://github.com/pop-os/shell/blob/cfa0c55e84b7ce339e5ce83832f76fee17e99d51/light.css#L20-L24
# Apple same color as nord(Nordic) https://github.com/EliverLara/Nordic/blob/5c53654fb6f3e0266ad8c481a099091e92f28274/gnome-shell/_colors.scss#L14-L15
(pop-shell.overrideAttrs (prev: {
preFixup =
prev.preFixup
+ ''
echo '.pop-shell-search-element:select{ background: #8fbcbb !important; color: #fefefe !important; }' >> $out/share/gnome-shell/extensions/pop-shell@system76.com/light.css
'';
}))
clipboard-history
kimpanel
just-perfection
dash-to-dock
color-picker
xremap
])
++ (with edge-pkgs; [
# 3rd-party bitwarden helper, because of official cli does not have many core features
# Use latest because of nixos-24.05 distributing version has a crucial bug: https://github.com/quexten/goldwarden/issues/190
goldwarden
]);

# https://github.com/NixOS/nixpkgs/issues/33282#issuecomment-523572259
environment.etc."xdg/user-dirs.defaults".text = ''
DESKTOP=Desktop
DOCUMENTS=Documents
DOWNLOAD=Downloads
MUSIC=Music
PICTURES=Pictures
PUBLICSHARE=Public
TEMPLATES=Templates
VIDEOS=Videos
'';

# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
Expand All @@ -305,16 +160,7 @@ in
# Or disable the firewall altogether.
# networking.firewall.enable = false;

programs.nix-ld.enable = false;

# https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/programs/firefox.nix
programs.firefox = {
enable = true;
languagePacks = [
"en-US"
"ja"
];
};
# programs.nix-ld.enable = false;

# Prefer NixOS modules rather than home-manager for easy setting up
programs.goldwarden = {
Expand All @@ -335,4 +181,22 @@ in
defaultNetwork.settings.dns_enabled = true;
};
};

# TODO: Reconsider to set C or EN for servers
# Select internationalisation properties.
i18n = {
defaultLocale = "ja_JP.UTF-8";

extraLocaleSettings = {
LC_ADDRESS = "ja_JP.UTF-8";
LC_IDENTIFICATION = "ja_JP.UTF-8";
LC_MEASUREMENT = "ja_JP.UTF-8";
LC_MONETARY = "ja_JP.UTF-8";
LC_NAME = "ja_JP.UTF-8";
LC_NUMERIC = "ja_JP.UTF-8";
LC_PAPER = "ja_JP.UTF-8";
LC_TELEPHONE = "ja_JP.UTF-8";
LC_TIME = "ja_JP.UTF-8";
};
};
}
4 changes: 0 additions & 4 deletions nixos/console.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# 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’).

{ homemade-pkgs, ... }:
{
# https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/config/console.nix
Expand Down
File renamed without changes.
Loading

0 comments on commit 9c5496a

Please sign in to comment.