From aabac5cecc11ef64d0238f65ad617504f0873000 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 28 Jun 2024 15:56:05 +0900 Subject: [PATCH] Begins NixOS for a desktop option (#576) Setup Linux GUI is a hard thing :weary: Some features are not yet completed. I might address them in following commits. --- .envrc | 4 + .github/workflows/ci-go.yml | 2 +- .github/workflows/ci-home.yml | 6 +- .github/workflows/ci-nix.yml | 3 +- .../workflows/update-flake-lock-and-ci.yml | 5 +- .gitignore | 3 + .vscode/settings.json | 3 +- README.md | 25 +- config/Firefox/README.md | 2 + config/Firefox/userChrome.css | 2 + config/fcitx5/config | 81 +++ config/fcitx5/profile | 23 + config/vscode/settings.json | 3 +- config/wezterm/wezterm.lua | 17 +- flake.lock | 619 +++++++++++++++++- flake.nix | 219 +++++-- home-manager/common.nix | 56 +- home-manager/{micro.nix => editor.nix} | 18 + home-manager/firefox.nix | 31 + home-manager/packages.nix | 10 +- home-manager/wsl.nix | 7 +- nixos/OneDrive.md | 8 + nixos/WARP.md | 11 + nixos/configuration.nix | 364 ++++++++++ pkgs/beedii.nix | 32 + pkgs/default.nix | 5 + windows/docs/NixOS.md | 0 27 files changed, 1443 insertions(+), 116 deletions(-) create mode 100644 config/fcitx5/config create mode 100644 config/fcitx5/profile rename home-manager/{micro.nix => editor.nix} (82%) create mode 100644 home-manager/firefox.nix create mode 100644 nixos/OneDrive.md create mode 100644 nixos/WARP.md create mode 100644 nixos/configuration.nix create mode 100644 pkgs/beedii.nix create mode 100644 windows/docs/NixOS.md diff --git a/.envrc b/.envrc index 197c0d59..6a2f2283 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,7 @@ #!/bin/bash use flake + +# To avoid absolute path for Nix and typos-lsp in vscode settings +TYPOS_LSP_PATH="$(command -v typos-lsp)" +export TYPOS_LSP_PATH diff --git a/.github/workflows/ci-go.yml b/.github/workflows/ci-go.yml index 17434538..64511743 100644 --- a/.github/workflows/ci-go.yml +++ b/.github/workflows/ci-go.yml @@ -27,7 +27,7 @@ jobs: matrix: os: - ubuntu-24.04 - - macos-14 # M1 - https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ + - macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811 - windows-latest runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/ci-home.yml b/.github/workflows/ci-home.yml index 0528b4b1..01927a28 100644 --- a/.github/workflows/ci-home.yml +++ b/.github/workflows/ci-home.yml @@ -23,16 +23,14 @@ on: jobs: home-manager: + if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft) timeout-minutes: 30 strategy: fail-fast: false matrix: os: - ubuntu-24.04 - - macos-14 # M1 - https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ - # Disabled macOS-13 because the runner is too slow. - # I have Intel Mac, but it have latest darwin. So only testing in ubuntu runner and macos-14 runner is enough. - # - macos-13 # Intel + - macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811 runs-on: ${{ matrix.os }} steps: diff --git a/.github/workflows/ci-nix.yml b/.github/workflows/ci-nix.yml index 59a8a679..8a0f8e59 100644 --- a/.github/workflows/ci-nix.yml +++ b/.github/workflows/ci-nix.yml @@ -22,12 +22,13 @@ on: jobs: tasks: + if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft) strategy: fail-fast: false matrix: os: - ubuntu-24.04 - - macos-14 # M1 - https://github.blog/changelog/2024-01-30-github-actions-introducing-the-new-m1-macos-runner-available-to-open-source/ + - macos-13 # Intel. Do not use macos-14 to prefer architecture - https://github.com/actions/runner-images/issues/9741#issuecomment-2075259811 runs-on: ${{ matrix.os }} timeout-minutes: 30 steps: diff --git a/.github/workflows/update-flake-lock-and-ci.yml b/.github/workflows/update-flake-lock-and-ci.yml index ec91b432..38c6497b 100644 --- a/.github/workflows/update-flake-lock-and-ci.yml +++ b/.github/workflows/update-flake-lock-and-ci.yml @@ -13,6 +13,7 @@ on: jobs: update-nixpkgs: + if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft) uses: kachick/selfup/.github/workflows/reusable-bump-flake-lock-and-selfup.yml@v1.1.3 with: app_id: ${{ vars.APP_ID }} @@ -20,9 +21,5 @@ jobs: pr-title: 'Bump flake.lock and related dependencies' optional-run: | nix run .#bump_completions - git add ./dependencies - # https://stackoverflow.com/q/34807971 - git update-index -q --really-refresh - git diff-index --quiet HEAD || git commit -m 'Update dprint completions' ./dependencies/dprint secrets: APP_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} diff --git a/.gitignore b/.gitignore index 3c7573a2..d091346d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ tmp/ .direnv +# NixOS +*hardware-configuration.nix result # macOS @@ -19,3 +21,4 @@ result winget-pkgs-*-raw.json *.bak +*.backup diff --git a/.vscode/settings.json b/.vscode/settings.json index 4d170a8e..6e8e7051 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -31,5 +31,6 @@ }, "gopls": { "build.buildFlags": ["-tags=linux,windows,darwin"] - } + }, + "stylua.searchBinaryInPATH": true } diff --git a/README.md b/README.md index d8c268df..3eca9691 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Also known as [盆栽(bonsai)](https://en.wikipedia.org/wiki/Bonsai) 🌳 ## For visitors -If you are using [Podman](https://podman.io/), you can test the pre-built [container-image](containers) as follows. +If you are using [Podman](https://podman.io/), you can test the pre-built [ubuntu container-image](containers) as follows. ```bash bash <(curl -fsSL https://raw.githubusercontent.com/kachick/dotfiles/main/containers/sandbox-with-ghcr.bash) latest @@ -27,7 +27,22 @@ nix run 'github:kachick/dotfiles#walk' nix run 'github:kachick/dotfiles#prs' ``` -## Linux(Ubuntu) +## NixOS + +This repository does not save the `hardware-configuration.nix` for each host,\ +so you should activate with `--impure` to load `/etc/nixos/hardware-configuration.nix` in your local + +```bash +sudo nixos-rebuild switch --impure --flake .#nixos-desktop +sudo reboot now +``` + +Some tools are not yet fully automated, read each docs. + +- [WARP](./nixos/WARP.md) +- [OneDrive](./nixos/OneDrive.md) + +## Ubuntu 1. Install [Nix](https://nixos.org/) package manager with [DeterminateSystems/nix-installer](https://github.com/DeterminateSystems/nix-installer) to enable [Flakes](https://nixos.wiki/wiki/Flakes) by default. ```bash @@ -50,11 +65,7 @@ nix run 'github:kachick/dotfiles#prs' - `user@linux` # Used in container - `kachick@linux` -## NixOS - -[Work in Progress](https://github.com/kachick/dotfiles/pull/576) - -## macOS(Darwin) +## macOS Activate `kachick@macbook` as Linux diff --git a/config/Firefox/README.md b/config/Firefox/README.md index a4ceaed0..0dadeaf5 100644 --- a/config/Firefox/README.md +++ b/config/Firefox/README.md @@ -2,6 +2,8 @@ ## How to change finder in page position from bottom to top? +In Nix, we can define this step with https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/firefox.nix + 1. `about:config` 1. Enable `toolkit.legacyUserProfileCustomizations.stylesheets` 1. Get profile folder path from `about:support` diff --git a/config/Firefox/userChrome.css b/config/Firefox/userChrome.css index 691342f2..d4ade4e6 100644 --- a/config/Firefox/userChrome.css +++ b/config/Firefox/userChrome.css @@ -1,7 +1,9 @@ +/* Making findbar to be top-left */ /* https://support.mozilla.org/lt/questions/1372399#answer-1492856 */ .browserContainer > findbar { -moz-box-ordinal-group: 0 !important; /* for 112 and older */ order: -1 !important; /* for 113 and newer */ border-top: none !important; border-bottom: 1px solid ThreeDShadow !important; + /* TODO: Realize top-right with adjusting the many checkboxes, can we make multiline? */ } diff --git a/config/fcitx5/config b/config/fcitx5/config new file mode 100644 index 00000000..91d1eaa5 --- /dev/null +++ b/config/fcitx5/config @@ -0,0 +1,81 @@ +[Hotkey] +# Enumerate when press trigger key repeatedly +EnumerateWithTriggerKeys=True +# Enumerate Input Method Forward +EnumerateForwardKeys= +# Enumerate Input Method Backward +EnumerateBackwardKeys= +# Skip first input method while enumerating +EnumerateSkipFirst=False + +[Hotkey/TriggerKeys] +0=Control+space +1=Zenkaku_Hankaku +2=Hangul + +[Hotkey/AltTriggerKeys] +0=Shift_L + +[Hotkey/EnumerateGroupForwardKeys] +0=Super+space + +[Hotkey/EnumerateGroupBackwardKeys] +0=Shift+Super+space + +[Hotkey/ActivateKeys] +0=Hangul_Hanja +1=Henkan + +[Hotkey/DeactivateKeys] +0=Hangul_Romaja +1=Muhenkan + +[Hotkey/PrevPage] +0=Up + +[Hotkey/NextPage] +0=Down + +[Hotkey/PrevCandidate] +0=Shift+Tab + +[Hotkey/NextCandidate] +0=Tab + +[Hotkey/TogglePreedit] +0=Control+Alt+P + +[Behavior] +# Active By Default +ActiveByDefault=False +# Share Input State +ShareInputState=No +# Show preedit in application +PreeditEnabledByDefault=True +# Show Input Method Information when switch input method +ShowInputMethodInformation=True +# Show Input Method Information when changing focus +showInputMethodInformationWhenFocusIn=False +# Show compact input method information +CompactInputMethodInformation=True +# Show first input method information +ShowFirstInputMethodInformation=True +# Default page size +DefaultPageSize=5 +# Override Xkb Option +OverrideXkbOption=False +# Custom Xkb Option +CustomXkbOption= +# Force Enabled Addons +EnabledAddons= +# Force Disabled Addons +DisabledAddons= +# Preload input method to be used by default +PreloadInputMethod=True +# Allow input method in the password field +AllowInputMethodForPassword=False +# Show preedit text when typing password +ShowPreeditForPassword=False +# Interval of saving user data in minutes +AutoSavePeriod=30 + diff --git a/config/fcitx5/profile b/config/fcitx5/profile new file mode 100644 index 00000000..5dc8c418 --- /dev/null +++ b/config/fcitx5/profile @@ -0,0 +1,23 @@ +[Groups/0] +# Group Name +Name=Default +# Layout +Default Layout=us +# Default Input Method +DefaultIM=mozc + +[Groups/0/Items/0] +# Name +Name=keyboard-us +# Layout +Layout= + +[Groups/0/Items/1] +# Name +Name=mozc +# Layout +Layout= + +[GroupOrder] +0=Default + diff --git a/config/vscode/settings.json b/config/vscode/settings.json index 85f84f20..ac5853c8 100644 --- a/config/vscode/settings.json +++ b/config/vscode/settings.json @@ -127,5 +127,6 @@ "editor.tabCompletion": "on", "files.defaultLanguage": "powershell", "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?", - "workbench.colorTheme": "Iceberg" + "workbench.colorTheme": "Iceberg", + "stylua.searchBinaryInPATH": true } diff --git a/config/wezterm/wezterm.lua b/config/wezterm/wezterm.lua index 8c31d1c9..4301693d 100644 --- a/config/wezterm/wezterm.lua +++ b/config/wezterm/wezterm.lua @@ -3,10 +3,14 @@ local config = wezterm.config_builder() local act = wezterm.action local launch_menu = {} local font_with_fallback = wezterm.font_with_fallback({ - { family = "PlemolJP Console NF", harfbuzz_features = { "zero" }, weight = "Medium" }, + { + family = "PlemolJP Console NF", + harfbuzz_features = { "zero" }, + weight = "Medium", + assume_emoji_presentation = false, + }, + { family = "Beedii", assume_emoji_presentation = true }, "源ノ角ゴシック Code JP", - "Noto Color Emoji", - "Cascadia Code", }) config.color_scheme = "iceberg-dark" @@ -30,6 +34,13 @@ if string.find(wezterm.target_triple, "pc-windows", 1, true) then }) end +-- Using in wayland requires non released versions +-- https://github.com/wez/wezterm/issues/5340 +if string.find(wezterm.target_triple, "-linux", 1, true) then + config.enable_wayland = true + config.use_ime = true +end + config.keys = { -- TODO: Consider to move into windows only combination { key = "v", mods = "CTRL", action = act.PasteFrom("Clipboard") }, diff --git a/flake.lock b/flake.lock index 2a4dc7fb..8844fb9c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,45 @@ { "nodes": { + "crane": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1716156051, + "narHash": "sha256-TjUX7WWRcrhuUxDHsR8pDR2N7jitqZehgCVSy3kBeS8=", + "owner": "ipetkov", + "repo": "crane", + "rev": "7443df1c478947bf96a2e699209f53b2db26209d", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "devshell": { + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "edge-nixpkgs": { "locked": { "lastModified": 1719254875, @@ -16,6 +56,94 @@ "type": "github" } }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1715865404, + "narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "freetype2": { + "flake": false, + "locked": { + "lastModified": 1687587065, + "narHash": "sha256-+Fh+/k+NWL5Ow9sDLtp8Cv/8rLNA1oByQQCIQS/bysY=", + "owner": "wez", + "repo": "freetype2", + "rev": "e4586d960f339cf75e2e0b34aee30a0ed8353c0d", + "type": "github" + }, + "original": { + "owner": "wez", + "repo": "freetype2", + "rev": "e4586d960f339cf75e2e0b34aee30a0ed8353c0d", + "type": "github" + } + }, + "harfbuzz": { + "flake": false, + "locked": { + "lastModified": 1711722720, + "narHash": "sha256-GdxcAPx5QyniSHPAN1ih28AD9JLUPR0ItqW9JEsl3pU=", + "owner": "harfbuzz", + "repo": "harfbuzz", + "rev": "63973005bc07aba599b47fdd4cf788647b601ccd", + "type": "github" + }, + "original": { + "owner": "harfbuzz", + "ref": "8.4.0", + "repo": "harfbuzz", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -37,6 +165,179 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1715930644, + "narHash": "sha256-W9pyM3/vePxrffHtzlJI6lDS3seANQ+Nqp+i58O46LI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "e3ad5108f54177e6520535768ddbf1e6af54b59d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "hyprcursor": { + "inputs": { + "hyprlang": [ + "xremap-flake", + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1715791817, + "narHash": "sha256-J069Uhv/gCMFLX1dSh2f+9ZTM09r1Nv3oUfocCnWKow=", + "owner": "hyprwm", + "repo": "hyprcursor", + "rev": "7c3aa03dffb53921e583ade3d4ae3f487e390e7e", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprcursor", + "type": "github" + } + }, + "hyprland": { + "inputs": { + "hyprcursor": "hyprcursor", + "hyprlang": "hyprlang", + "hyprwayland-scanner": "hyprwayland-scanner", + "nixpkgs": "nixpkgs_5", + "systems": "systems_3", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1716063601, + "narHash": "sha256-lH2CLdRQFtbQVauhLFDbPWTGmj7LgblMg2dq9thd0Zc=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "f8857e6072bd85b95393499688872aaf7f088b5b", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "xdph", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "xdph", + "systems" + ] + }, + "locked": { + "lastModified": 1691753796, + "narHash": "sha256-zOEwiWoXk3j3+EoF3ySUJmberFewWlagvewDRuWYAso=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "0c2ce70625cb30aef199cb388f99e19a61a6ce03", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "hyprlang": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1715791527, + "narHash": "sha256-HhQ4zvGHrRjR63ltySSeg+x+0jb0lepiutWdnFhLRoo=", + "owner": "hyprwm", + "repo": "hyprlang", + "rev": "969cb076e5b76f2e823aeca1937a3e1f159812ee", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprlang", + "type": "github" + } + }, + "hyprwayland-scanner": { + "inputs": { + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1715879663, + "narHash": "sha256-/DwglRvj4XF4ECdNtrCIbthleszAZBwOiXG5A6r0K/c=", + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "rev": "f5181a068c1b06f2db51f6222e50a0c665a2b0c3", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprwayland-scanner", + "type": "github" + } + }, + "libpng": { + "flake": false, + "locked": { + "lastModified": 1549245649, + "narHash": "sha256-1+cRp0Ungme/OGfc9kGJbklYIWAFxk8Il1M+NV4KSgw=", + "owner": "glennrp", + "repo": "libpng", + "rev": "8439534daa1d3a5705ba92e653eda9251246dd61", + "type": "github" + }, + "original": { + "owner": "glennrp", + "repo": "libpng", + "rev": "8439534daa1d3a5705ba92e653eda9251246dd61", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1719426051, @@ -53,11 +354,327 @@ "type": "github" } }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1714640452, + "narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1718276985, + "narHash": "sha256-u1fA0DYQYdeG+5kDm1bOoGcHtX0rtC7qs2YA2N1X++I=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3f84a279f1a6290ce154c5531378acc827836fbb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1715266358, + "narHash": "sha256-doPgfj+7FFe9rfzWo1siAV2mVCasW+Bh8I1cToAXEE4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f1010e0469db743d14519a1efd37e23f8513d714", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_5": { + "locked": { + "lastModified": 1715787315, + "narHash": "sha256-cYApT0NXJfqBkKcci7D9Kr4CBYZKOQKDYA23q8XNuWg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "33d1e753c82ffc557b4a585c77de43d4c922ebb5", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_6": { + "locked": { + "lastModified": 1716190602, + "narHash": "sha256-xYRimrR0duWvokWQEvB87bSsICeCvvX9DxpUOzCfsDE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5a5ac83292c7842072318f57d68a48474f8bd34d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_7": { + "locked": { + "lastModified": 1708475490, + "narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "0e74ca98a74bc7270d28838369593635a5db3260", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "edge-nixpkgs": "edge-nixpkgs", "home-manager": "home-manager", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "wezterm-flake": "wezterm-flake", + "xremap-flake": "xremap-flake" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "wezterm-flake", + "flake-utils" + ], + "nixpkgs": [ + "wezterm-flake", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718417877, + "narHash": "sha256-s8QrTANEtY6UxzfkcBfoN93bgW9aCRIq54LPRVNu/4c=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7c2d603cb67c974ef8c5cfee1150060dbb299e04", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_3": { + "locked": { + "lastModified": 1689347949, + "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", + "owner": "nix-systems", + "repo": "default-linux", + "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default-linux", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_7" + }, + "locked": { + "lastModified": 1715940852, + "narHash": "sha256-wJqHMg/K6X3JGAE9YLM0LsuKrKb4XiBeVaoeMNlReZg=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "2fba33a182602b9d49f0b2440513e5ee091d838b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "wezterm-flake": { + "inputs": { + "flake-utils": "flake-utils", + "freetype2": "freetype2", + "harfbuzz": "harfbuzz", + "libpng": "libpng", + "nixpkgs": "nixpkgs_2", + "rust-overlay": "rust-overlay", + "zlib": "zlib" + }, + "locked": { + "dir": "nix", + "lastModified": 1718638535, + "narHash": "sha256-wKkhtsMPIXBtAUNIQ4O6b2kahcaub3+JzF4V7NFsA4Q=", + "owner": "wez", + "repo": "wezterm", + "rev": "cb1406860a23896ca6935696169644d140e29208", + "type": "github" + }, + "original": { + "dir": "nix", + "owner": "wez", + "repo": "wezterm", + "type": "github" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "hyprlang": [ + "xremap-flake", + "hyprland", + "hyprlang" + ], + "nixpkgs": [ + "xremap-flake", + "hyprland", + "nixpkgs" + ], + "systems": [ + "xremap-flake", + "hyprland", + "systems" + ] + }, + "locked": { + "lastModified": 1715788457, + "narHash": "sha256-32HOkjSIyANphV0p5gIwP4ONU/CcinhwOyVFB+tL/d0=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "af7c87a32f5d67eb2ada908a6a700f4e74831943", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } + }, + "xremap": { + "flake": false, + "locked": { + "lastModified": 1716230517, + "narHash": "sha256-ww0w5dCnbyqS64lOSLx+eURSi85uFlvIOUvA7Xlky1E=", + "owner": "k0kubun", + "repo": "xremap", + "rev": "98bb9ee1b1e35bfed6370dbbdf5703a8799fec11", + "type": "github" + }, + "original": { + "owner": "k0kubun", + "ref": "v0.9.0", + "repo": "xremap", + "type": "github" + } + }, + "xremap-flake": { + "inputs": { + "crane": "crane", + "devshell": "devshell", + "flake-parts": "flake-parts", + "home-manager": "home-manager_2", + "hyprland": "hyprland", + "nixpkgs": "nixpkgs_6", + "treefmt-nix": "treefmt-nix", + "xremap": "xremap" + }, + "locked": { + "lastModified": 1716231478, + "narHash": "sha256-54nR//0El4CKIwIeWYHY0/HFeh+2s00/NUuemH5DDDA=", + "owner": "xremap", + "repo": "nix-flake", + "rev": "7a9a071a84c9b5bdd48d4b3eacf6efa448665aed", + "type": "github" + }, + "original": { + "owner": "xremap", + "repo": "nix-flake", + "type": "github" + } + }, + "zlib": { + "flake": false, + "locked": { + "lastModified": 1484501380, + "narHash": "sha256-j5b6aki1ztrzfCqu8y729sPar8GpyQWIrajdzpJC+ww=", + "owner": "madler", + "repo": "zlib", + "rev": "cacf7f1d4e3d44d871b605da3b647f07d718623f", + "type": "github" + }, + "original": { + "owner": "madler", + "ref": "v1.2.11", + "repo": "zlib", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index a8e59dd9..5386fd74 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,10 @@ url = "github:nix-community/home-manager/release-24.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + # https://github.com/xremap/nix-flake/blob/master/docs/HOWTO.md + xremap-flake.url = "github:xremap/nix-flake"; + # https://github.com/wez/wezterm/pull/3547#issuecomment-1915820504 + wezterm-flake.url = "github:wez/wezterm?dir=nix"; }; outputs = @@ -20,8 +24,11 @@ nixpkgs, edge-nixpkgs, home-manager, - }: + xremap-flake, + wezterm-flake, + }@inputs: let + inherit (self) outputs; # Candidates: https://github.com/NixOS/nixpkgs/blob/release-24.05/lib/systems/flake-systems.nix forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" @@ -34,8 +41,16 @@ type = "app"; program = nixpkgs.lib.getExe pkg; }; + + packages = forAllSystems ( + system: + (import ./pkgs { + pkgs = nixpkgs.legacyPackages.${system}; + edge-pkgs = edge-nixpkgs.legacyPackages.${system}; + }) + ); in - rec { + { # nixfmt will be official # - https://github.com/NixOS/nixfmt/issues/153 # - https://github.com/NixOS/nixfmt/issues/129 @@ -73,6 +88,7 @@ edge-pkgs.yamlfmt stylua typos + typos-lsp go_1_22 goreleaser trivy @@ -81,14 +97,6 @@ } ); - packages = forAllSystems ( - system: - (import ./pkgs { - pkgs = nixpkgs.legacyPackages.${system}; - edge-pkgs = edge-nixpkgs.legacyPackages.${system}; - }) - ); - apps = forAllSystems (system: { # example: `nix run .#home-manager -- switch -n -b backup --flake .#user@linux` # https://github.com/NixOS/nix/issues/6448#issuecomment-1132855605 @@ -106,76 +114,147 @@ prs = mkApp packages.${system}.prs; }); - homeConfigurations = { - "kachick@linux" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ ./home-manager/kachick.nix ]; - extraSpecialArgs = { - homemade-pkgs = packages.x86_64-linux; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; + nixosConfigurations = + let + system = "x86_64-linux"; + edge-pkgs = import edge-nixpkgs { + inherit system; + config = { + allowUnfree = true; + }; }; - }; + homemade-pkgs = packages.${system}; + in + { + "nixos-desktop" = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + ./nixos/configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "backup"; + users.kachick = import ./home-manager/kachick.nix; - "kachick@wsl" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ - ./home-manager/kachick.nix - ./home-manager/wsl.nix - ]; - extraSpecialArgs = { - homemade-pkgs = packages.x86_64-linux; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; - }; - }; + extraSpecialArgs = { + inherit homemade-pkgs edge-pkgs; + }; + }; + } + xremap-flake.nixosModules.default + { + # Modmap for single key rebinds + services.xremap.config = { + modmap = [ + { + name = "Global"; + remap = { + "CapsLock" = "Ctrl_L"; + "Alt_L" = { + "held" = "Alt_L"; + "alone" = "Muhenkan"; + "alone_timeout_millis" = 500; + }; + "Alt_R" = "Henkan"; + }; + } + ]; - "kachick@macbook" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-darwin; - modules = [ ./home-manager/kachick.nix ]; - extraSpecialArgs = { - homemade-pkgs = packages.x86_64-darwin; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin; + # Keymap for key combo rebinds + keymap = [ + { + name = "Gnome lancher"; + remap = { + "Alt-Space" = "LEFTMETA"; + }; + } + ]; + }; + } + ]; + specialArgs = { + inherit + inputs + outputs + homemade-pkgs + edge-pkgs + ; + }; }; }; - "github-actions@ubuntu-24.04" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ - # Prefer "kachick" over "common" only here. - # Using values as much as possible as actual values to create a robust CI - ./home-manager/kachick.nix - { home.username = "runner"; } - ]; - extraSpecialArgs = { - homemade-pkgs = packages.x86_64-linux; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; + homeConfigurations = + let + x86-Linux = { + pkgs = nixpkgs.legacyPackages.x86_64-linux; + extraSpecialArgs = { + homemade-pkgs = packages.x86_64-linux; + edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; + }; }; - }; - "github-actions@macos-14" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.aarch64-darwin; - modules = [ - # Prefer "kachick" over "common" only here. - # Using values as much as possible as actual values to create a robust CI - ./home-manager/kachick.nix - { home.username = "runner"; } - ]; - extraSpecialArgs = { - homemade-pkgs = packages.aarch64-darwin; - edge-pkgs = edge-nixpkgs.legacyPackages.aarch64-darwin; + x86-macOS = { + pkgs = nixpkgs.legacyPackages.x86_64-darwin; + extraSpecialArgs = { + homemade-pkgs = packages.x86_64-darwin; + edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-darwin; + }; }; - }; + in + { + "kachick@linux" = home-manager.lib.homeManagerConfiguration ( + x86-Linux // { modules = [ ./home-manager/kachick.nix ]; } + ); - "user@linux" = home-manager.lib.homeManagerConfiguration { - pkgs = nixpkgs.legacyPackages.x86_64-linux; - modules = [ - ./home-manager/common.nix - { home.username = "user"; } - ]; - extraSpecialArgs = { - homemade-pkgs = packages.x86_64-linux; - edge-pkgs = edge-nixpkgs.legacyPackages.x86_64-linux; - }; + "kachick@wsl" = home-manager.lib.homeManagerConfiguration ( + x86-Linux + // { + modules = [ + ./home-manager/kachick.nix + ./home-manager/wsl.nix + ]; + } + ); + + "kachick@macbook" = home-manager.lib.homeManagerConfiguration ( + x86-macOS // { modules = [ ./home-manager/kachick.nix ]; } + ); + + "github-actions@ubuntu-24.04" = home-manager.lib.homeManagerConfiguration ( + x86-Linux + // { + # Prefer "kachick" over "common" only here. + # Using values as much as possible as actual values to create a robust CI + modules = [ + ./home-manager/kachick.nix + { home.username = "runner"; } + ]; + } + ); + + "github-actions@macos-13" = home-manager.lib.homeManagerConfiguration ( + x86-macOS + // { + # Prefer "kachick" over "common" only here. + # Using values as much as possible as actual values to create a robust CI + modules = [ + ./home-manager/kachick.nix + { home.username = "runner"; } + ]; + } + ); + + "user@linux" = home-manager.lib.homeManagerConfiguration ( + x86-Linux + // { + modules = [ + ./home-manager/common.nix + { home.username = "user"; } + ]; + } + ); }; - }; }; } diff --git a/home-manager/common.nix b/home-manager/common.nix index 19f2e6e7..c60ca2c0 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -15,7 +15,8 @@ ./gpg.nix ./ssh.nix ./git.nix - ./micro.nix + ./editor.nix + ./firefox.nix ./darwin.nix ]; @@ -174,6 +175,36 @@ # TODO: Automate that needs to call `Install-Module -Name PSFzfHistory` first xdg.configFile."powershell/Microsoft.PowerShell_profile.ps1".source = ../config/powershell/Profile.ps1; + # https://github.com/savedra1/clipse/issues/41#issuecomment-2099269175 + xdg.configFile."autostart/clipse-clipboard-manager.desktop".text = '' + [Desktop Entry] + Name=clipse + Comment=Clipse event listener autostart. + Exec=${lib.getExe pkgs.clipse} --listen %f + Terminal=false + Type=Application + ''; + + # https://github.com/NixOS/nixpkgs/issues/222925#issuecomment-1514112861 + xdg.configFile."autostart/userdirs.desktop".text = '' + [Desktop Entry] + Exec=xdg-user-dirs-update + TryExec=xdg-user-dirs-update + NoDisplay=true + StartupNotify=false + Type=Application + X-KDE-AutostartScript=true + X-KDE-autostart-phase=1 + ''; + + # https://wiki.archlinux.org/title/wayland + # Didn't work if the electron is bundled, so unfit for nixpkgs distributing apps + # xdg.configFile."electron-flags.conf".text = '' + # --enable-features=UseOzonePlatform + # --ozone-platform=wayland + # --enable-wayland-ime + # ''; + xdg.dataFile."tmpbin/.keep".text = ""; home.file.".hushlogin".text = "This file disables daily login message. Not depend on this text."; @@ -192,6 +223,13 @@ # typos does not have global config feature, this is used in git hooks for https://github.com/kachick/dotfiles/issues/412 xdg.configFile."typos/typos.toml".source = ../typos.toml; + xdg.configFile."fcitx5/config" = { + source = ../config/fcitx5/config; + }; + xdg.configFile."fcitx5/profile" = { + source = ../config/fcitx5/profile; + }; + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/fzf.nix # https://github.com/junegunn/fzf/blob/master/README.md programs.fzf = rec { @@ -244,22 +282,6 @@ }; }; - # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/vim.nix - # https://nixos.wiki/wiki/Vim - programs.vim = { - enable = true; - # nix-env -f '' -qaP -A vimPlugins - plugins = [ pkgs.vimPlugins.iceberg-vim ]; - - settings = { - background = "dark"; - }; - extraConfig = '' - colorscheme iceberg - set termguicolors - ''; - }; - # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/bat.nix programs.bat = { enable = true; diff --git a/home-manager/micro.nix b/home-manager/editor.nix similarity index 82% rename from home-manager/micro.nix rename to home-manager/editor.nix index cd25d228..bedee043 100644 --- a/home-manager/micro.nix +++ b/home-manager/editor.nix @@ -69,4 +69,22 @@ in colorscheme = "nord-16"; }; }; + + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/vim.nix + # https://nixos.wiki/wiki/Vim + programs.vim = { + enable = true; + # nix-env -f '' -qaP -A vimPlugins + plugins = [ pkgs.vimPlugins.iceberg-vim ]; + + settings = { + background = "dark"; + }; + extraConfig = '' + colorscheme iceberg + set termguicolors + ''; + }; + + # Don't add unfree packages like vscode here for using in containers } diff --git a/home-manager/firefox.nix b/home-manager/firefox.nix new file mode 100644 index 00000000..7e4e3da5 --- /dev/null +++ b/home-manager/firefox.nix @@ -0,0 +1,31 @@ +{ lib, pkgs, ... }: + +lib.mkMerge [ + # Firefox package does not support both M1 and Intel like x86_64-apple-darwin + (lib.mkIf pkgs.stdenv.isLinux { + # https://github.com/nix-community/home-manager/blob/release-24.05/modules/programs/firefox.nix + programs.firefox = { + enable = true; + profiles.default = { + isDefault = true; + settings = { + # UI lang + "intl.locale.requested" = "ja"; + + "browser.shell.checkDefaultBrowser" = false; + + # Required for playing DRM contents as Spotify + "media.eme.enabled" = true; + + # Enabling userChrome.css + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + + # Disabling alt+ keybinds for lanchers + # https://www.reddit.com/r/firefox/comments/129w85w/is_there_a_way_to_disable_firefox_alt_keyboard/ + "ui.key.menuAccessKeyFocuses" = false; + }; + userChrome = builtins.readFile ../config/Firefox/userChrome.css; + }; + }; + }) +] diff --git a/home-manager/packages.nix b/home-manager/packages.nix index 090cd64c..d80b7585 100644 --- a/home-manager/packages.nix +++ b/home-manager/packages.nix @@ -73,8 +73,12 @@ with pkgs; bottom # `btm`, alt top xh # alt HTTPie zellij - wezterm + + # Do not install wezterm in home-manager layer for non NixOS + # - Released wezterm versions are broken on wayland + # - Using nightly needs to take long build time, avoiding it for CI time alacritty + typos hyperfine difftastic @@ -105,8 +109,6 @@ with pkgs; source-han-code-jp # Includes many definitions, useful for fallback inconsolata - mplus-outline-fonts.githubRelease # https://github.com/NixOS/nixpkgs/blob/c56f470377573b3170b62242ce21abcc196cb4ef/pkgs/data/fonts/mplus-outline-fonts/default.nix#L33 - # pkgs.sarasa-gothic # Large filesize # Includes follows in each repository if needed, not in global # gcc @@ -134,7 +136,6 @@ with pkgs; zj p g - podman walk updeps bench_shells @@ -153,4 +154,5 @@ with pkgs; ++ (lib.optionals stdenv.isDarwin [ # https://github.com/NixOS/nixpkgs/issues/240819 pinentry_mac + homemade-pkgs.podman ]) diff --git a/home-manager/wsl.nix b/home-manager/wsl.nix index a0fe5e65..117438e9 100644 --- a/home-manager/wsl.nix +++ b/home-manager/wsl.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, homemade-pkgs, ... }: { # https://github.com/nix-community/home-manager/blob/release-24.05/modules/systemd.nix#L161-L173 @@ -35,5 +35,8 @@ }; }; - home.packages = [ pkgs.wslu ]; + home.packages = [ + pkgs.wslu + homemade-pkgs.podman + ]; } diff --git a/nixos/OneDrive.md b/nixos/OneDrive.md new file mode 100644 index 00000000..8ccbdd62 --- /dev/null +++ b/nixos/OneDrive.md @@ -0,0 +1,8 @@ +https://nixos.wiki/wiki/OneDrive + +```bash +onedrive +systemctl --user enable onedrive@onedrive.service +systemctl --user start onedrive@onedrive.service +systemctl --user status onedrive@onedrive.service +``` diff --git a/nixos/WARP.md b/nixos/WARP.md new file mode 100644 index 00000000..d836348e --- /dev/null +++ b/nixos/WARP.md @@ -0,0 +1,11 @@ +Just installing as [this](https://github.com/NixOS/nixpkgs/issues/213177#issuecomment-1905556283) does not start connections. + +You should https://developers.cloudflare.com/warp-client/get-started/linux/ + +```bash +warp-cli registration new +warp-cli connect + +# Make sure warp=on +curl -OL https://www.cloudflare.com/cdn-cgi/trace/ +``` diff --git a/nixos/configuration.nix b/nixos/configuration.nix new file mode 100644 index 00000000..17857aac --- /dev/null +++ b/nixos/configuration.nix @@ -0,0 +1,364 @@ +# 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’). + +{ + inputs, + config, + pkgs, + edge-pkgs, + lib, + ... +}: +let + beedii = pkgs.callPackage ../pkgs/beedii.nix { }; +in +{ + imports = [ + # Include the results of the hardware scan. + /etc/nixos/hardware-configuration.nix + ]; + + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; + + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "nixos-desktop"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # 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; + + # Set your time zone. + 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; + + # Select internationalisation properties. + i18n.defaultLocale = "ja_JP.UTF-8"; + + i18n.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"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + # services.xserver.displayManager.sddm.wayland.enable = true; + # services.xserver.desktopManager.gnome.enable = true; + services = { + desktopManager.plasma6.enable = true; + # displayManager = { + # sddm.enable = true; + # defaultSession = "plasma"; + # }; + }; + environment.plasma6.excludePackages = with pkgs.kdePackages; [ + plasma-browser-integration + konsole + oxygen + ]; + environment.sessionVariables = { + MOZ_ENABLE_WAYLAND = "1"; + SSH_ASKPASS_REQUIRE = "prefer"; + }; + + services.packagekit = { + enable = true; + }; + + # Configure keymap in X11 + services.xserver = { + xkb = { + layout = "us"; + variant = ""; + }; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Didn't work for current device + # services.fprintd = { + # enable = true; + + # # https://gitlab.freedesktop.org/libfprint/libfprint/-/issues/402#note_1860665 + + # # https://discourse.nixos.org/t/cannot-enroll-fingerprints-with-fprintd-no-devices-available/40362 + # tod = { + # enable = true; + # driver = pkgs.libfprint-2-tod1-elan; + # }; + + # # https://github.com/NixOS/nixpkgs/issues/298150 + # package = pkgs.fprintd.overrideAttrs { + # mesonCheckFlags = [ + # "--no-suite" + # "fprintd:TestPamFprintd" + # ]; + # }; + # }; + + # https://sbulav.github.io/nix/nix-fingerprint-authentication/ + security.pam.services.swaylock = { }; + security.pam.services.swaylock.fprintAuth = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + 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.libinput = { + enable = true; + mouse.naturalScrolling = true; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users = { + kachick = { + isNormalUser = true; + description = "An admin"; + extraGroups = [ + "networkmanager" + "wheel" + ]; + packages = [ + # Don't install spotify, it does not activate IME and no binary cache with the unfree license. + # Use the Web Player via Firefox + ]; + }; + }; + + i18n.inputMethod = { + enabled = "fcitx5"; + + fcitx5.addons = [ + pkgs.fcitx5-mozc + pkgs.fcitx5-gtk + ]; + + fcitx5.waylandFrontend = true; + }; + + 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.micro; + SYSTEMD_EDITOR = lib.getExe pkgs.micro; + VISUAL = lib.getExe pkgs.micro; + }; + + services.dbus.packages = [ config.i18n.inputMethod.package ]; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + micro + + skk-dicts + skktools + + alacritty + # Using latest to avoid stable release and wayland problems https://github.com/wez/wezterm/issues/5340 + inputs.wezterm-flake.packages.${pkgs.system}.default + + wget + curl + git + bat + coreutils + findutils + fd + fzf + ripgrep + + # Don't use clipcat, copyq for wayland problem + # Dont' use cliphist for electron problem: https://www.reddit.com/r/NixOS/comments/1d57zbj/problem_with_cliphist_and_electron_apps/ + clipse + # Required in clipse + wl-clipboard + + # 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 + + (signal-desktop.overrideAttrs (prev: { + preFixup = + prev.preFixup + + '' + gappsWrapperArgs+=( + --add-flags "--enable-features=UseOzonePlatform" + --add-flags "--ozone-platform=wayland" + --add-flags "--enable-wayland-ime" + ) + ''; + })) + + ## Unfree packages + + (edge-pkgs.vscode.override { + # https://wiki.archlinux.org/title/Wayland#Electron + # https://github.com/NixOS/nixpkgs/blob/3f8b7310913d9e4805b7e20b2beabb27e333b31f/pkgs/applications/editors/vscode/generic.nix#L207-L214 + commandLineArgs = builtins.concatStringsSep " " [ + "--enable-features=UseOzonePlatform" + "--ozone-platform=wayland" + "--enable-wayland-ime" + ]; + }) + + # 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*` + (edge-pkgs.google-chrome.override { + # 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 = builtins.concatStringsSep " " [ "--enable-wayland-ime" ]; + }) + + cloudflare-warp + ]; + + # 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; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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 = "24.05"; # Did you read the comment? + + programs.nix-ld.enable = false; + + fonts = { + enableDefaultPackages = true; + packages = with pkgs; [ + ibm-plex + plemoljp-nf + inconsolata + mplus-outline-fonts.githubRelease + # sarasa-gothic # Avoiding because of the large filesize + + # emoji + noto-fonts-color-emoji + beedii + twemoji-color-font + + # Source Han family includes many definitions, useful for fallback + source-han-code-jp + source-han-sans-japanese + source-han-serif-japanese + ]; + fontconfig = { + enable = true; + hinting.enable = true; + defaultFonts = { + serif = [ + "IBM Plex Serif" + "Source Han Serif" + ]; + sansSerif = [ + "IBM Plex Sans" + "Source Han Sans" + ]; + monospace = [ + "PlemolJP Console NF" + "Source Han Code JP" + ]; + emoji = [ + "Beedii" + "Noto Color Emoji" + ]; + }; + }; + }; + + # https://nixos.wiki/wiki/Podman + virtualisation = { + containers.enable = true; + podman = { + enable = true; + + # Create a `docker` alias for podman, to use it as a drop-in replacement + dockerCompat = true; + + # Required for containers under podman-compose to be able to talk to each other. + defaultNetwork.settings.dns_enabled = true; + }; + }; + + # https://nixos.wiki/wiki/OneDrive + services.onedrive.enable = true; + + # https://github.com/NixOS/nixpkgs/issues/213177#issuecomment-1905556283 + systemd.packages = [ pkgs.cloudflare-warp ]; # for warp-cli + systemd.targets.multi-user.wants = [ "warp-svc.service" ]; # causes warp-svc to be started automatically +} diff --git a/pkgs/beedii.nix b/pkgs/beedii.nix new file mode 100644 index 00000000..8112a20e --- /dev/null +++ b/pkgs/beedii.nix @@ -0,0 +1,32 @@ +{ + lib, + stdenvNoCC, + fetchzip, +}: + +stdenvNoCC.mkDerivation rec { + pname = "beedii"; + version = "1.0.0"; + + src = fetchzip { + url = "https://github.com/webkul/beedii/releases/download/v${version}/beedii.zip"; + hash = "sha256-MefkmWl7LdhQiePpixKcatoIeOTlrRaO3QA9xWAxJ4Q="; + stripRoot = false; + }; + + installPhase = '' + runHook preInstall + + install -Dm444 Fonts/*.ttf -t $out/share/fonts/truetype/${pname} + + runHook postInstall + ''; + + meta = with lib; { + description = "Free Hand Drawn Emoji Font"; + homepage = "https://github.com/webkul/beedii"; + license = licenses.cc0; + platforms = platforms.all; + maintainers = with maintainers; [ kachick ]; + }; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 0ff50c14..32b28699 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -101,6 +101,11 @@ rec { # Do no include "nix" in inputs: https://github.com/NixOS/nix/issues/5473 runtimeInputs = with pkgs; [ mise ]; text = '' + if [ -f /etc/NIXOS ]; then + echo 'Needless this updater for NixOS, so exit with nothing' + exit 1 + fi + echo 'this updater assume you have the privilege and sudo command' set -x diff --git a/windows/docs/NixOS.md b/windows/docs/NixOS.md new file mode 100644 index 00000000..e69de29b