Compare commits

...

2 Commits

Author SHA1 Message Date
7eb32cfabc feat: impure symlink 2025-12-28 11:07:50 +08:00
f9308dda9e refactor: config/hosts => hosts 2025-12-28 09:22:15 +08:00
46 changed files with 45 additions and 37 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
export IMPURE_ROOT=$(pwd)

View File

@@ -1,28 +1,29 @@
root := `pwd`
NH := "IMPURE_ROOT=" + root + " nh"
all: fmt switch all: fmt switch
switch: switch:
@echo "Rebuilding NixOS..." @echo "Rebuilding NixOS..."
@nh os switch . @{{NH}} os switch . --impure
switch-offline: switch-offline:
@echo "Rebuilding NixOS without net..." @echo "Rebuilding NixOS without net..."
@nh os switch . --no-net @{{NH}} os switch . --impure --no-net
offline: alias offline := switch-offline
@echo "Rebuilding NixOS without net..."
@nh os switch . --no-net
boot: boot:
@echo "Rebuilding NixOS..." @echo "Rebuilding NixOS..."
@nh os boot . @{{NH}} os boot . --impure
test: test:
@echo "Rebuilding NixOS..." @echo "Rebuilding NixOS..."
@nh os test . @{{NH}} os test . --impure
vm: vm:
@echo "Building NixOS VM..." @echo "Building NixOS VM..."
@nh os build-vm . @{{NH}} os build-vm . --impure
update: update:
@echo "Updating flakes..." @echo "Updating flakes..."
@@ -47,5 +48,3 @@ gc:
fmt: fmt:
@echo "Formatting nix files..." @echo "Formatting nix files..."
@nix fmt @nix fmt
.PHONY: all switch switch-offline boot test vm update repl cleandry clean gc fmt

View File

@@ -10,7 +10,7 @@ Currently, this repository contains the nix code that builds:
2. NixOS home server 2. NixOS home server
3. NixOS WSL 3. NixOS WSL
See [./config/hosts](./config/hosts) for details of each host. See [./hosts](./hosts) for details of each host.
## Why NixOS & Flakes? ## Why NixOS & Flakes?
@@ -25,23 +25,6 @@ As for Flakes, refer to
This configuration uses [flake-parts](https://flake.parts/) for better flake organization and modularity, This configuration uses [flake-parts](https://flake.parts/) for better flake organization and modularity,
enabling declarative host definitions and cleaner separation of concerns. enabling declarative host definitions and cleaner separation of concerns.
## Components
| | NixOS(Wayland) |
| ----------------------------- | :------------------------------------------- |
| **Window Manager** | Niri |
| **Desktop Shell** | Noctalia Shell |
| **Terminal Emulator** | Kitty |
| **Input method framework** | Fcitx5 |
| **Shell** | Zsh |
| **Netease Cloudmusic Player** | go-musicfox |
| **Media Player** | mpv |
| **Text Editor** | Neovim |
| **Fonts** | Noto Sans CJK & Jetbrains Mono & Nerd Font |
| **Filesystem** | Btrfs |
And more...
## Folder Structure ## Folder Structure
- `modules/` - custom NixOS modules - `modules/` - custom NixOS modules
@@ -55,7 +38,7 @@ And more...
- `profiles/desktop.nix` - desktop environment configuration - `profiles/desktop.nix` - desktop environment configuration
- `profiles/server.nix` - server-specific configuration - `profiles/server.nix` - server-specific configuration
- `profiles/wsl.nix` - WSL-specific configuration - `profiles/wsl.nix` - WSL-specific configuration
- `config/hosts/<name>/` - host-specific configs - `hosts/<name>/` - host-specific configs
- `flake/` - flake-parts modules - `flake/` - flake-parts modules
- `flake/hosts.nix` - declarative host definitions - `flake/hosts.nix` - declarative host definitions
- `lib/` - custom nix library - `lib/` - custom nix library
@@ -63,4 +46,4 @@ And more...
- `overlays/` - nixpkgs overlays - `overlays/` - nixpkgs overlays
- `vars.nix` - my variables - `vars.nix` - my variables
- `secrets/` - secrets managed by sops-nix. see [./secrets](./secrets) for details - `secrets/` - secrets managed by sops-nix. see [./secrets](./secrets) for details
- `flake.nix` - flake entry - `flake.nix` - flake entry

View File

@@ -51,7 +51,7 @@ in
type = lib.types.listOf lib.types.deferredModule; type = lib.types.listOf lib.types.deferredModule;
default = ( default = (
lib.umport { lib.umport {
paths = [ ../config/hosts/${name} ]; paths = [ ../hosts/${name} ];
extraExcludePredicate = path: lib.hasInfix "/_" (toString path); extraExcludePredicate = path: lib.hasInfix "/_" (toString path);
recursive = true; recursive = true;
} }

View File

@@ -1,8 +1,8 @@
{ lib, inputs }: { lib, inputs }:
lib.extend ( lib.extend (
self: super: { self: super: {
umport = import ./umport.nix { lib = self; };
inherit (inputs.home-manager.lib) hm; inherit (inputs.home-manager.lib) hm;
umport = import ./umport.nix { lib = self; };
haumea = inputs.haumea.lib; haumea = inputs.haumea.lib;
infuse = (import inputs.infuse { inherit lib; }).v1.infuse; infuse = (import inputs.infuse { inherit lib; }).v1.infuse;
} }

View File

@@ -2,6 +2,7 @@
config, config,
lib, lib,
pkgs, pkgs,
impure,
... ...
}: }:
let let
@@ -14,11 +15,8 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
xdg.configFile."nvim/init.lua".source = ./nvim/init.lua; xdg.configFile."nvim/init.lua".source = impure.mkImpureLink ./nvim/init.lua;
xdg.configFile."nvim/lua" = { xdg.configFile."nvim/lua".source = impure.mkImpureLink ./nvim/lua;
source = ./nvim/lua;
recursive = true;
};
programs.neovim = { programs.neovim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;

View File

@@ -15,6 +15,7 @@ in
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
my.hm = { my.hm = {
home.packages = with pkgs; [ home.packages = with pkgs; [
just
gnumake gnumake
github-cli # gh github-cli # gh
]; ];

26
modules/impure.nix Normal file
View File

@@ -0,0 +1,26 @@
{
lib,
pkgs,
self,
...
}:
let
relativePath =
path:
assert lib.types.path.check path;
lib.strings.removePrefix (toString self) (toString path);
mkImpureLink =
path:
let
relative = relativePath path;
in
pkgs.runCommandLocal relative { } "ln -s ${lib.escapeShellArg (impureRoot + relative)} $out";
impureRoot =
let
impureRoot = builtins.getEnv "IMPURE_ROOT";
in
if impureRoot == "" then throw "IMPURE_ROOT is not set" else impureRoot;
in
{
_module.args.impure = { inherit mkImpureLink; };
}