feat: simplify flake.nix

This commit is contained in:
Ryan Yin
2023-07-26 20:07:42 +08:00
parent eebbb9f5e6
commit 204cb03922
70 changed files with 1183 additions and 1165 deletions
+1
View File
@@ -1,2 +1,3 @@
result result
result/ result/
.DS_Store
+5 -5
View File
@@ -13,13 +13,13 @@
i3: i3:
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo
hyprland: hypr:
nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo
debug_i3: i3-debug:
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo --show-trace --verbose nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo --show-trace --verbose
debug_hyprland: hypr-debug:
nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo --show-trace --verbose nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo --show-trace --verbose
update: update:
@@ -49,11 +49,11 @@ bright:
darwin-set-proxy: darwin-set-proxy:
sudo python3 scripts/darwin_set_proxy.py sudo python3 scripts/darwin_set_proxy.py
darwin: darwin-set-proxy ha: darwin-set-proxy
nix build .#darwinConfigurations.harmonica.system nix build .#darwinConfigurations.harmonica.system
./result/sw/bin/darwin-rebuild switch --flake . ./result/sw/bin/darwin-rebuild switch --flake .
darwin-debug: darwin-set-proxy ha-debug: darwin-set-proxy
nix build .#darwinConfigurations.harmonica.system --show-trace --verbose nix build .#darwinConfigurations.harmonica.system --show-trace --verbose
./result/sw/bin/darwin-rebuild switch --flake .#harmonica --show-trace --verbose ./result/sw/bin/darwin-rebuild switch --flake .#harmonica --show-trace --verbose
+3 -3
View File
@@ -58,17 +58,17 @@ sudo nixos-rebuild switch --flake .
make i3 make i3
# or we can deploy with details # or we can deploy with details
make debug_i3 make i3-debug
``` ```
For MacOS, use the following commands: For MacOS, use the following commands:
```bash ```bash
# deploy the darwin configuration(harmonicia) # deploy the darwin configuration(harmonicia)
make darwin make ha
# deploy with details # deploy with details
make darwin-debug make ha-debug
``` ```
## Install Apps from Flatpak ## Install Apps from Flatpak
Generated
+79 -56
View File
@@ -60,26 +60,6 @@
"type": "github" "type": "github"
} }
}, },
"darwin_2": {
"inputs": {
"nixpkgs": [
"nixpkgs-darwin"
]
},
"locked": {
"lastModified": 1689516967,
"narHash": "sha256-sFAa33wkQHanmij/uhfGduIDK8z4dJAita/rK6u9pvE=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "61662a63bfe1726588c1da6b412df86d8ca94d63",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"flake-compat": { "flake-compat": {
"locked": { "locked": {
"lastModified": 1688025799, "lastModified": 1688025799,
@@ -185,16 +165,16 @@
"xdph": "xdph" "xdph": "xdph"
}, },
"locked": { "locked": {
"lastModified": 1689160271, "lastModified": 1689766295,
"narHash": "sha256-mEKF6Wcx+wSF/eos/91A7LxhFLDYhSnQnLpwZF13ntg=", "narHash": "sha256-2OuPIcw2WOUc/zjrH7JZHWe1byuMjqP6Zz7D4qsi10s=",
"owner": "hyprwm", "owner": "hyprwm",
"repo": "Hyprland", "repo": "Hyprland",
"rev": "5e577acf516b80173f695a458c2cc188a4d64560", "rev": "b08b72358ad549fd066e5be0fc3aa4c9df367607",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "hyprwm", "owner": "hyprwm",
"ref": "v0.27.0", "ref": "v0.27.2",
"repo": "Hyprland", "repo": "Hyprland",
"type": "github" "type": "github"
} }
@@ -226,11 +206,11 @@
"nixpkgs-lib": "nixpkgs-lib" "nixpkgs-lib": "nixpkgs-lib"
}, },
"locked": { "locked": {
"lastModified": 1689509371, "lastModified": 1690114105,
"narHash": "sha256-ESRIO7E8PfKF5cL2ymdrQrvj8LORET24Wbpl0XMzhog=", "narHash": "sha256-QOY9FXZ4pWjlDPdZKkLNNMHS+ct1+4wu8lrcua7+chw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "lib-aggregate", "repo": "lib-aggregate",
"rev": "d75813d1b691b829a5b459bc676e2b1d71d2c15e", "rev": "d923660039d7e793712ba93f633778046f5e6087",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -256,17 +236,38 @@
"url": "ssh://git@github.com/ryan4yin/nix-secrets.git" "url": "ssh://git@github.com/ryan4yin/nix-secrets.git"
} }
}, },
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs-darwin"
]
},
"locked": {
"lastModified": 1690368313,
"narHash": "sha256-1MG/pU2riawknpYaTfaynKJPaIKFnQiYTTCFJAjXM5Q=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "94212ebe32948471a1aa11baa5c576ce60d54589",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-eval-jobs": { "nix-eval-jobs": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs_4" "nixpkgs": "nixpkgs_4",
"treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1689318580, "lastModified": 1689903701,
"narHash": "sha256-ccMZzE0Du6I7RtAuDZbERsBZRGnFcwXTAnSQqGd7mOY=", "narHash": "sha256-kW1Rke5wLqw8XHVyiWw7qIKZR911GCsbOg5SkgKH1Uc=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nix-eval-jobs", "repo": "nix-eval-jobs",
"rev": "f88571cfc9132e8f2768aa41d57f5f471941d4b6", "rev": "fcaf7773e3a6713b78dacfd442339a96cfab405f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -298,11 +299,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1689558522, "lastModified": 1690133435,
"narHash": "sha256-diNpqSRebzvT3P4fLX+40VWZbf2H2hraJDDdg5NJSj0=", "narHash": "sha256-YNZiefETggroaTLsLJG2M+wpF0pJPwiauKG4q48ddNU=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixos-generators", "repo": "nixos-generators",
"rev": "11c98929963a95ad3830960a9216d00e2f792502", "rev": "b1171de4d362c022130c92d7c8adc4bf2b83d586",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -329,11 +330,11 @@
}, },
"nixpkgs-darwin": { "nixpkgs-darwin": {
"locked": { "locked": {
"lastModified": 1689503327, "lastModified": 1690298576,
"narHash": "sha256-qVwzYLA8oT2oWNDXO0A3bZHOhoPOihIB9T677+Hor1E=", "narHash": "sha256-RLgIGS04t4Rd0viqsx2e9dGViKB6nVsGmO11EagCWmM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f64b9738da8e86195766147e9752c67fccee006c", "rev": "88f63d511092e95d28e9a7c98534595c53de1048",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -345,11 +346,11 @@
}, },
"nixpkgs-lib": { "nixpkgs-lib": {
"locked": { "locked": {
"lastModified": 1689469483, "lastModified": 1690073998,
"narHash": "sha256-2SBhY7rZQ/iNCxe04Eqxlz9YK9KgbaTMBssq3/BgdWY=", "narHash": "sha256-qmK+VMvflwUzQSQl4XVP5kbodYLAKThNzq6mZrOM2Mo=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs.lib", "repo": "nixpkgs.lib",
"rev": "02fea408f27186f139153e1ae88f8ab2abd9c22c", "rev": "d0545f65611a9625f161d0ff02627bc364e024f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -360,11 +361,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1689534811, "lastModified": 1690179384,
"narHash": "sha256-jnSUdzD/414d94plCyNlvTJJtiTogTep6t7ZgIKIHiE=", "narHash": "sha256-+arbgqFTAtoeKtepW9wCnA0njCOyoiDFyl0Q0SBSOtE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222", "rev": "b12803b6d90e2e583429bb79b859ca53c348b39a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -382,11 +383,11 @@
"nixpkgs": "nixpkgs_5" "nixpkgs": "nixpkgs_5"
}, },
"locked": { "locked": {
"lastModified": 1689585449, "lastModified": 1690384532,
"narHash": "sha256-D6TL+9EbDcGLNmpneuGXnonjNWlS563TOoghU/W/k88=", "narHash": "sha256-Nc9d6GPajVdSj02aBDkAAq93fdLUtRXP9EIfwKn3Uq4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixpkgs-wayland", "repo": "nixpkgs-wayland",
"rev": "97941d1936213031ae7ca948ba27aa1bd141a630", "rev": "729cabdcc73e84963751dd65163048e9ff1a1a75",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -413,11 +414,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1689503327, "lastModified": 1690271650,
"narHash": "sha256-qVwzYLA8oT2oWNDXO0A3bZHOhoPOihIB9T677+Hor1E=", "narHash": "sha256-qwdsW8DBY1qH+9luliIH7VzgwvL+ZGI3LZWC0LTiDMI=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "f64b9738da8e86195766147e9752c67fccee006c", "rev": "6dc93f0daec55ee2f441da385aaf143863e3d671",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -445,11 +446,11 @@
}, },
"nixpkgs_5": { "nixpkgs_5": {
"locked": { "locked": {
"lastModified": 1689534811, "lastModified": 1690179384,
"narHash": "sha256-jnSUdzD/414d94plCyNlvTJJtiTogTep6t7ZgIKIHiE=", "narHash": "sha256-+arbgqFTAtoeKtepW9wCnA0njCOyoiDFyl0Q0SBSOtE=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6cee3b5893090b0f5f0a06b4cf42ca4e60e5d222", "rev": "b12803b6d90e2e583429bb79b859ca53c348b39a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -463,10 +464,10 @@
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"astronvim": "astronvim", "astronvim": "astronvim",
"darwin": "darwin_2",
"home-manager": "home-manager_2", "home-manager": "home-manager_2",
"hyprland": "hyprland", "hyprland": "hyprland",
"mysecrets": "mysecrets", "mysecrets": "mysecrets",
"nix-darwin": "nix-darwin",
"nixos-generators": "nixos-generators", "nixos-generators": "nixos-generators",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_3",
"nixpkgs-darwin": "nixpkgs-darwin", "nixpkgs-darwin": "nixpkgs-darwin",
@@ -489,15 +490,37 @@
"type": "github" "type": "github"
} }
}, },
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs-wayland",
"nix-eval-jobs",
"nixpkgs"
]
},
"locked": {
"lastModified": 1689620039,
"narHash": "sha256-BtNwghr05z7k5YMdq+6nbue+nEalvDepuA7qdQMAKoQ=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "719c2977f958c41fa60a928e2fbc50af14844114",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"wlroots": { "wlroots": {
"flake": false, "flake": false,
"locked": { "locked": {
"host": "gitlab.freedesktop.org", "host": "gitlab.freedesktop.org",
"lastModified": 1686753331, "lastModified": 1689611045,
"narHash": "sha256-KovjVFwcuoUO0eu/UiWrnD3+m/K+SHSAVIz4xF9K1XA=", "narHash": "sha256-3RTOlQabkNetQ4O4UzSf57JPco9VGVHhSU1ls5uKBeE=",
"owner": "wlroots", "owner": "wlroots",
"repo": "wlroots", "repo": "wlroots",
"rev": "7e7633abf09b362d0bad9e3fc650fd692369291d", "rev": "7791ffe0584c4ac13c170e1661ce33bdbd4a9b9e",
"type": "gitlab" "type": "gitlab"
}, },
"original": { "original": {
+137 -198
View File
@@ -10,7 +10,7 @@
# the nixConfig here only affects the flake itself, not the system configuration! # the nixConfig here only affects the flake itself, not the system configuration!
nixConfig = { nixConfig = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = ["nix-command" "flakes"];
substituters = [ substituters = [
# replace official cache with a mirror located in China # replace official cache with a mirror located in China
@@ -30,7 +30,6 @@
]; ];
}; };
# This is the standard format for flake.nix. `inputs` are the dependencies of the flake, # This is the standard format for flake.nix. `inputs` are the dependencies of the flake,
# Each item in `inputs` will be passed as a parameter to the `outputs` function after being pulled and built. # Each item in `inputs` will be passed as a parameter to the `outputs` function after being pulled and built.
inputs = { inputs = {
@@ -43,7 +42,7 @@
# for macos # for macos
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin"; nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.05-darwin";
darwin = { nix-darwin = {
url = "github:lnl7/nix-darwin"; url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs-darwin"; inputs.nixpkgs.follows = "nixpkgs-darwin";
}; };
@@ -58,7 +57,7 @@
}; };
# modern window compositor # modern window compositor
hyprland.url = "github:hyprwm/Hyprland/v0.27.0"; hyprland.url = "github:hyprwm/Hyprland/v0.27.2";
# community wayland nixpkgs # community wayland nixpkgs
nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland"; nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
@@ -72,11 +71,17 @@
agenix.url = "github:ryantm/agenix/0d8c5325fc81daf00532e3e26c6752f7bcde1143"; agenix.url = "github:ryantm/agenix/0d8c5325fc81daf00532e3e26c6752f7bcde1143";
# AstroNvim is an aesthetic and feature-rich neovim config. # AstroNvim is an aesthetic and feature-rich neovim config.
astronvim = { url = "github:AstroNvim/AstroNvim/v3.33.3"; flake = false; }; astronvim = {
url = "github:AstroNvim/AstroNvim/v3.33.3";
flake = false;
};
# my private secrets, it's a private repository, you need to replace it with your own. # my private secrets, it's a private repository, you need to replace it with your own.
# use ssh protocol to authenticate via ssh-agent/ssh-key, and shallow clone to save time # use ssh protocol to authenticate via ssh-agent/ssh-key, and shallow clone to save time
mysecrets = { url = "git+ssh://git@github.com/ryan4yin/nix-secrets.git?shallow=1"; flake = false; }; mysecrets = {
url = "git+ssh://git@github.com/ryan4yin/nix-secrets.git?shallow=1";
flake = false;
};
}; };
# The `outputs` function will return all the build results of the flake. # The `outputs` function will return all the build results of the flake.
@@ -84,204 +89,138 @@
# parameters in `outputs` are defined in `inputs` and can be referenced by their names. # parameters in `outputs` are defined in `inputs` and can be referenced by their names.
# However, `self` is an exception, this special parameter points to the `outputs` itself (self-reference) # However, `self` is an exception, this special parameter points to the `outputs` itself (self-reference)
# The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function. # The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function.
outputs = outputs = inputs @ {
inputs@{ self self,
, nixpkgs nixpkgs,
, darwin nixpkgs-unstable,
, home-manager nix-darwin,
, nixos-generators home-manager,
, ... nixos-generators,
}: ...
}: let
username = "ryan";
x64_system = "x86_64-linux";
x64_darwin = "x86_64-darwin";
allSystems = [x64_system x64_darwin];
let nixosSystem = import ./lib/nixosSystem.nix;
x64_system = "x86_64-linux"; macosSystem = import ./lib/macosSystem.nix;
x64_specialArgs = {
# use unstable branch for some packages to get the latest updates # 星野 アイ, Hoshino Ai
pkgs-unstable = import inputs.nixpkgs-unstable { idol_ai_modules_i3 = {
system = x64_system; # refer the `system` parameter form outer scope recursively nixos-modules = [
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
} // inputs;
# 星野 アイ, Hoshino Ai
idol_ai_modules_i3 = [
./hosts/idols/ai ./hosts/idols/ai
./modules/nixos/i3.nix ./modules/nixos/i3.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = x64_specialArgs;
home-manager.users.ryan = import ./home/linux/desktop-i3.nix;
}
]; ];
idol_ai_modules_hyprland = [ home-module = import ./home/linux/desktop-i3.nix;
};
idol_ai_modules_hyprland = {
nixos-modules = [
./hosts/idols/ai ./hosts/idols/ai
./modules/nixos/hyprland.nix ./modules/nixos/hyprland.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = x64_specialArgs;
home-manager.users.ryan = import ./home/linux/desktop-hyprland.nix;
}
]; ];
# 星野 愛久愛海, Hoshino Akuamarin home-module = import ./home/linux/desktop-hyprland.nix;
idol_aquamarine_modules = [
./hosts/idols/aquamarine
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = x64_specialArgs;
home-manager.users.ryan = import ./home/linux/server.nix;
}
];
# 星野 瑠美衣, Hoshino Rubii
idol_ruby_modules = [
./hosts/idols/ruby
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = x64_specialArgs;
home-manager.users.ryan = import ./home/linux/server.nix;
}
];
# 有馬 かな, Arima Kana
idol_kana_modules = [
./hosts/idols/kana
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = x64_specialArgs;
home-manager.users.ryan = import ./home/linux/server.nix;
}
];
in {
nixosConfigurations = let system = x64_system; specialArgs = x64_specialArgs; in {
ai_i3 = nixpkgs.lib.nixosSystem { # ai with i3 window manager
inherit system specialArgs;
modules = idol_ai_modules_i3;
};
ai_hyprland = nixpkgs.lib.nixosSystem { # ai with hyprland compositor
inherit system specialArgs;
modules = idol_ai_modules_hyprland;
};
aquamarine = nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules = idol_aquamarine_modules;
};
ruby = nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules = idol_ruby_modules;
};
kana = nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules = idol_kana_modules;
};
};
# macOS's configuration, for work.
darwinConfigurations."harmonica" = let
system = "x86_64-darwin";
specialArgs = {
# use unstable branch for some packages to get the latest updates
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
} // inputs;
in
darwin.lib.darwinSystem {
inherit system specialArgs;
modules = [
./hosts/harmonica
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.ryan = import ./home/darwin;
}
];
};
formatter = {
# format the nix code in this flake
# alejandra is a nix formatter with a beautiful output
x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
x86_64-darwin = nixpkgs.legacyPackages.x86_64-darwin.alejandra;
};
packages.x86_64-linux =
# take images for idols
# https://github.com/nix-community/nixos-generators
let system = x64_system; specialArgs = x64_specialArgs; in {
# Hoshino Ai is a physical machine, so we need to generate an iso image for it.
ai_i3 = nixos-generators.nixosGenerate { # ai with i3 window manager
inherit system specialArgs;
modules = idol_ai_modules_i3;
format = "iso";
};
ai_hyprland = nixos-generators.nixosGenerate { # ai with hyprland compositor
inherit system specialArgs;
modules = idol_ai_modules_hyprland;
format = "iso";
};
# Hoshino Aquamarine is a virtual machine running on Proxmox VE.
aquamarine = nixos-generators.nixosGenerate {
inherit system specialArgs;
modules = idol_aquamarine_modules ++ [
({config, ...}: {
proxmox.qemuConf.name = "aquamarine-nixos-${config.system.nixos.label}";
})
];
# proxmox's configuration:
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/virtualisation/proxmox-image.nix
#
# after resize the disk, it will grow partition automatically.
# and it alse had qemu-guest-agent installed by default.
format = "proxmox";
};
# Hoshino Rubii is a vm too.
ruby = nixos-generators.nixosGenerate {
inherit system specialArgs;
modules = idol_ruby_modules ++ [
({config, ...}: {
proxmox.qemuConf.name = "ruby-nixos-${config.system.nixos.label}";
})
];
format = "proxmox";
};
# Kana is a vm too.
kana = nixos-generators.nixosGenerate {
inherit system specialArgs;
modules = idol_kana_modules ++ [
({config, ...}: {
proxmox.qemuConf.name = "kana-nixos-${config.system.nixos.label}";
})
];
format = "proxmox";
};
};
}; };
# 星野 愛久愛海, Hoshino Akuamarin
idol_aquamarine_modules = {
nixos-modules = [
./hosts/idols/aquamarine
];
home-module = import ./home/linux/server.nix;
};
# 星野 瑠美衣, Hoshino Rubii
idol_ruby_modules = {
nixos-modules = [
./hosts/idols/ruby
];
home-module = import ./home/linux/server.nix;
};
# 有馬 かな, Arima Kana
idol_kana_modules = {
nixos-modules = [
./hosts/idols/kana
];
home-module = import ./home/linux/server.nix;
};
in {
nixosConfigurations = let
system = x64_system;
specialArgs =
{
inherit username;
# use unstable branch for some packages to get the latest updates
pkgs-unstable = import nixpkgs-unstable {
system = x64_system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
}
// inputs;
base_args = {
inherit home-manager nixos-generators system specialArgs;
};
stable_args = base_args // {inherit nixpkgs;};
unstable_args = base_args // {nixpkgs = nixpkgs-unstable;};
in {
# ai with i3 window manager
ai_i3 = nixosSystem (idol_ai_modules_i3 // stable_args);
# ai with hyprland compositor
ai_hyprland = nixosSystem (idol_ai_modules_hyprland // stable_args);
aquamarine = nixosSystem (idol_aquamarine_modules // unstable_args);
ruby = nixosSystem (idol_ruby_modules // unstable_args);
kana = nixosSystem (idol_kana_modules // unstable_args);
};
# take images for idols
# https://github.com/nix-community/nixos-generators
packages."${x64_system}" =
nixpkgs.lib.genAttrs [
"ai_i3"
"ai_hyprland"
] (
host:
self.nixosConfigurations.${host}.config.formats.iso
)
// nixpkgs.lib.genAttrs [
"aquamarine"
"ruby"
"kana"
] (
host:
self.nixosConfigurations.${host}.config.formats.proxmox
);
# macOS's configuration, for work.
darwinConfigurations."harmonica" = let
system = x64_darwin;
specialArgs =
{
# use unstable branch for some packages to get the latest updates
pkgs-unstable = import nixpkgs-unstable {
inherit system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
}
// inputs;
in
macosSystem {
inherit nix-darwin home-manager system specialArgs;
darwin-modules = [
./hosts/harmonica
];
home-module = import ./home/darwin;
};
# format the nix code in this flake
# alejandra is a nix formatter with a beautiful output
formatter = nixpkgs.lib.genAttrs allSystems (
system:
nixpkgs.legacyPackages.${system}.alejandra
);
};
} }
+7 -4
View File
@@ -1,5 +1,8 @@
{ lib, stdenvNoCC, fetchgit }: {
lib,
stdenvNoCC,
fetchgit,
}:
stdenvNoCC.mkDerivation rec { stdenvNoCC.mkDerivation rec {
pname = "icomoon-feather-font"; pname = "icomoon-feather-font";
version = "2023-05-06"; version = "2023-05-06";
@@ -8,7 +11,7 @@ stdenvNoCC.mkDerivation rec {
src = fetchgit { src = fetchgit {
url = "https://github.com/adi1090x/polybar-themes.git"; url = "https://github.com/adi1090x/polybar-themes.git";
rev = "47b66337a92a1afd2240ed7094ffcb039cc686cf"; # git commit id rev = "47b66337a92a1afd2240ed7094ffcb039cc686cf"; # git commit id
sparseCheckout = [ "fonts/feather.ttf" ]; # only fetch the feather.ttf file sparseCheckout = ["fonts/feather.ttf"]; # only fetch the feather.ttf file
# the sha256 is used to verify the integrity of the downloaded source, and alse cache the build result. # the sha256 is used to verify the integrity of the downloaded source, and alse cache the build result.
# so if you copy other package src's sha256, you will get a cached build result of that package, and all configs in this file will be ignored. # so if you copy other package src's sha256, you will get a cached build result of that package, and all configs in this file will be ignored.
@@ -33,7 +36,7 @@ stdenvNoCC.mkDerivation rec {
Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency, and flexibility. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency, and flexibility.
''; '';
license = licenses.mit; license = licenses.mit;
maintainers = [ maintainers.ryan4yin ]; maintainers = [maintainers.ryan4yin];
platforms = platforms.all; platforms = platforms.all;
}; };
} }
+71 -68
View File
@@ -1,5 +1,4 @@
{ pkgs, ... }: {pkgs, ...}:
########################################################### ###########################################################
# #
# Alacritty Configuration # Alacritty Configuration
@@ -18,80 +17,84 @@
# Note: Alacritty do not have support for Tabs, and any graphic protocol. # Note: Alacritty do not have support for Tabs, and any graphic protocol.
# #
########################################################### ###########################################################
{ {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
}; };
xdg.configFile."alacritty/alacritty.yml".text = '' xdg.configFile."alacritty/alacritty.yml".text =
import: ''
# all alacritty themes can be found at import:
# https://github.com/alacritty/alacritty-theme # all alacritty themes can be found at
- ~/.config/alacritty/theme_catppuccino.yml # https://github.com/alacritty/alacritty-theme
- ~/.config/alacritty/theme_catppuccino.yml
window: window:
# Background opacity # Background opacity
#
# Window opacity as a floating point number from `0.0` to `1.0`.
# The value `0.0` is completely transparent and `1.0` is opaque.
opacity: 0.95
# Startup Mode (changes require restart)
#
# Values for `startup_mode`:
# - Windowed
# - Maximized
# - Fullscreen
#
# Values for `startup_mode` (macOS only):
# - SimpleFullscreen
startup_mode: Windowed
# Allow terminal applications to change Alacritty's window title.
dynamic_title: true
# Make `Option` key behave as `Alt` (macOS only):
# - OnlyLeft
# - OnlyRight
# - Both
# - None (default)
option_as_alt: Both
scrolling:
# Maximum number of lines in the scrollback buffer.
# Specifying '0' will disable scrolling.
history: 10000
# Scrolling distance multiplier.
#multiplier: 3
# Font configuration
font:
# Normal (roman) font face
bold:
family: JetBrainsMono Nerd Font
italic:
family: JetBrainsMono Nerd Font
normal:
family: JetBrainsMono Nerd Font
bold_italic:
# Font family
# #
# If the bold italic family is not specified, it will fall back to the # Window opacity as a floating point number from `0.0` to `1.0`.
# value specified for the normal font. # The value `0.0` is completely transparent and `1.0` is opaque.
family: JetBrainsMono Nerd Font opacity: 0.95
'' + (if pkgs.stdenv.isDarwin then ''
# Point size
size: 14
shell: # force nushell as default shell on macOS
program: /run/current-system/sw/bin/nu
'' else ''
# holder identation
# Point size
size: 13
'');
# Startup Mode (changes require restart)
#
# Values for `startup_mode`:
# - Windowed
# - Maximized
# - Fullscreen
#
# Values for `startup_mode` (macOS only):
# - SimpleFullscreen
startup_mode: Windowed
# Allow terminal applications to change Alacritty's window title.
dynamic_title: true
# Make `Option` key behave as `Alt` (macOS only):
# - OnlyLeft
# - OnlyRight
# - Both
# - None (default)
option_as_alt: Both
scrolling:
# Maximum number of lines in the scrollback buffer.
# Specifying '0' will disable scrolling.
history: 10000
# Scrolling distance multiplier.
#multiplier: 3
# Font configuration
font:
# Normal (roman) font face
bold:
family: JetBrainsMono Nerd Font
italic:
family: JetBrainsMono Nerd Font
normal:
family: JetBrainsMono Nerd Font
bold_italic:
# Font family
#
# If the bold italic family is not specified, it will fall back to the
# value specified for the normal font.
family: JetBrainsMono Nerd Font
''
+ (
if pkgs.stdenv.isDarwin
then ''
# Point size
size: 14
shell: # force nushell as default shell on macOS
program: /run/current-system/sw/bin/nu
''
else ''
# holder identation
# Point size
size: 13
''
);
xdg.configFile."alacritty/theme_catppuccino.yml".source = ./theme_catppuccino.yml; xdg.configFile."alacritty/theme_catppuccino.yml".source = ./theme_catppuccino.yml;
} }
+1 -3
View File
@@ -1,5 +1,4 @@
{ ... }: {...}: {
{
imports = [ imports = [
./alacritty ./alacritty
../server ../server
@@ -10,5 +9,4 @@
./media.nix ./media.nix
./shell.nix ./shell.nix
]; ];
} }
+12 -9
View File
@@ -1,6 +1,8 @@
{ pkgs, pkgs-unstable, ... }:
{ {
pkgs,
pkgs-unstable,
...
}: {
############################################################# #############################################################
# #
# Basic settings for development environment # Basic settings for development environment
@@ -36,13 +38,14 @@
gnumake # used by this repo, to simplify the deployment gnumake # used by this repo, to simplify the deployment
# python # python
(python311.withPackages (ps: with ps; [ (python311.withPackages (ps:
ipython with ps; [
pandas ipython
requests pandas
pyquery requests
pyyaml pyquery
])) pyyaml
]))
# db related # db related
dbeaver dbeaver
+25 -13
View File
@@ -1,5 +1,8 @@
{ lib, pkgs, ... }: {
lib,
pkgs,
...
}:
########################################################### ###########################################################
# #
# Kitty Configuration # Kitty Configuration
@@ -28,20 +31,29 @@
font = { font = {
name = "JetBrainsMono Nerd Font"; name = "JetBrainsMono Nerd Font";
# use different font size on macOS # use different font size on macOS
size = if pkgs.stdenv.isDarwin then 14 else 13; size =
if pkgs.stdenv.isDarwin
then 14
else 13;
}; };
settings = { settings =
background_opacity = "0.95"; {
macos_option_as_alt = true; # Option key acts as Alt on macOS background_opacity = "0.95";
scrollback_lines = 10000; macos_option_as_alt = true; # Option key acts as Alt on macOS
enable_audio_bell = false; scrollback_lines = 10000;
} // (if pkgs.stdenv.isDarwin then { enable_audio_bell = false;
# macOS specific settings, force kitty to use nushell as default shell }
shell = "/run/current-system/sw/bin/nu"; // (
} else {}); if pkgs.stdenv.isDarwin
then {
# macOS specific settings, force kitty to use nushell as default shell
shell = "/run/current-system/sw/bin/nu";
}
else {}
);
# macOS specific settings # macOS specific settings
darwinLaunchOptions = [ "--start-as=fullscreen" ]; darwinLaunchOptions = ["--start-as=fullscreen"];
}; };
} }
+4 -3
View File
@@ -1,6 +1,7 @@
{ pkgs {
, config pkgs,
, ... config,
...
}: }:
# processing audio/video # processing audio/video
{ {
+28 -27
View File
@@ -1,5 +1,8 @@
{ pkgs, astronvim, ... }: {
pkgs,
astronvim,
...
}:
############################################################################### ###############################################################################
# #
# AstroNvim's configuration and all its dependencies # AstroNvim's configuration and all its dependencies
@@ -123,10 +126,9 @@
extraPackages = []; extraPackages = [];
# currently we use lazy.nvim as neovim's package manager, so comment this one. # currently we use lazy.nvim as neovim's package manager, so comment this one.
plugins = with pkgs.vimPlugins;[ plugins = with pkgs.vimPlugins; [
# search all the plugins using https://search.nixos.org/packages # search all the plugins using https://search.nixos.org/packages
luasnip luasnip
]; ];
}; };
}; };
@@ -144,12 +146,12 @@
#-- python #-- python
nodePackages.pyright # python language server nodePackages.pyright # python language server
python311Packages.black # python formatter python311Packages.black # python formatter
python311Packages.ruff-lsp python311Packages.ruff-lsp
#-- rust #-- rust
rust-analyzer rust-analyzer
cargo # rust package manager cargo # rust package manager
rustfmt rustfmt
#-- zig #-- zig
@@ -159,18 +161,18 @@
nil nil
rnix-lsp rnix-lsp
# nixd # nixd
statix # Lints and suggestions for the nix programming language statix # Lints and suggestions for the nix programming language
deadnix # Find and remove unused code in .nix source files deadnix # Find and remove unused code in .nix source files
alejandra # Nix Code Formatter alejandra # Nix Code Formatter
#-- golang #-- golang
go go
gomodifytags gomodifytags
iferr # generate error handling code for go iferr # generate error handling code for go
impl # generate function implementation for go impl # generate function implementation for go
gotools # contains tools like: godoc, goimports, etc. gotools # contains tools like: godoc, goimports, etc.
gopls # go language server gopls # go language server
delve # go debugger delve # go debugger
#-- lua #-- lua
stylua stylua
@@ -194,26 +196,25 @@
terraform-ls terraform-ls
jsonnet jsonnet
jsonnet-language-server jsonnet-language-server
hadolint # Dockerfile linter hadolint # Dockerfile linter
#-- Others #-- Others
taplo # TOML language server / formatter / validator taplo # TOML language server / formatter / validator
nodePackages.yaml-language-server nodePackages.yaml-language-server
sqlfluff # SQL linter sqlfluff # SQL linter
actionlint # GitHub Actions linter actionlint # GitHub Actions linter
buf # protoc plugin for linting and formatting buf # protoc plugin for linting and formatting
proselint # English prose linter proselint # English prose linter
#-- Misc #-- Misc
tree-sitter # common language parser/highlighter tree-sitter # common language parser/highlighter
nodePackages.prettier # common code formatter nodePackages.prettier # common code formatter
marksman # language server for markdown marksman # language server for markdown
glow # markdown previewer glow # markdown previewer
#-- Optional Requirements: #-- Optional Requirements:
gdu # disk usage analyzer, required by AstroNvim gdu # disk usage analyzer, required by AstroNvim
ripgrep # fast search tool, required by AstroNvim's '<leader>fw'(<leader> is space key) ripgrep # fast search tool, required by AstroNvim's '<leader>fw'(<leader> is space key)
]; ];
}; };
} }
+1 -3
View File
@@ -1,5 +1,4 @@
{...}: {
{ ... }: {
programs.bash = { programs.bash = {
# load the alias file for work # load the alias file for work
bashrcExtra = '' bashrcExtra = ''
@@ -22,5 +21,4 @@
source /etc/agenix/alias-for-work.nushell source /etc/agenix/alias-for-work.nushell
''; '';
}; };
} }
+1 -1
View File
@@ -1,4 +1,4 @@
{ ... }: { {...}: {
programs.bash = { programs.bash = {
enable = true; enable = true;
enableCompletion = true; enableCompletion = true;
+2 -5
View File
@@ -1,6 +1,5 @@
{ ... }: {...}: {
{ # a cat(1) clone with syntax highlighting and Git integration.
# a cat(1) clone with syntax highlighting and Git integration.
programs.bat = { programs.bat = {
enable = true; enable = true;
config = { config = {
@@ -12,6 +11,4 @@
Catppuccin-mocha = builtins.readFile ./Catppuccin-mocha.tmTheme; Catppuccin-mocha = builtins.readFile ./Catppuccin-mocha.tmTheme;
}; };
}; };
} }
+3 -5
View File
@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
home.packages = with pkgs; [ home.packages = with pkgs; [
neofetch neofetch
nnn # terminal file manager nnn # terminal file manager
@@ -20,12 +18,12 @@
# networking tools # networking tools
mtr # A network diagnostic tool mtr # A network diagnostic tool
iperf3 iperf3
dnsutils # `dig` + `nslookup` dnsutils # `dig` + `nslookup`
ldns # replacement of `dig`, it provide the command `drill` ldns # replacement of `dig`, it provide the command `drill`
aria2 # A lightweight multi-protocol & multi-source command-line download utility aria2 # A lightweight multi-protocol & multi-source command-line download utility
socat # replacement of openbsd-netcat socat # replacement of openbsd-netcat
nmap # A utility for network discovery and security auditing nmap # A utility for network discovery and security auditing
ipcalc # it is a calculator for the IPv4/v6 addresses ipcalc # it is a calculator for the IPv4/v6 addresses
# misc # misc
cowsay cowsay
+1 -3
View File
@@ -1,5 +1,4 @@
{ ... }: {...}: {
{
imports = [ imports = [
./bat ./bat
./nushell ./nushell
@@ -11,5 +10,4 @@
./git.nix ./git.nix
./starship.nix ./starship.nix
]; ];
} }
+6 -5
View File
@@ -1,13 +1,14 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: { }: {
# `programs.git` will generate the config file: ~/.config/git/config # `programs.git` will generate the config file: ~/.config/git/config
# to make git use this config file, `~/.gitconfig` should not exist! # to make git use this config file, `~/.gitconfig` should not exist!
# #
# https://git-scm.com/docs/git-config#Documentation/git-config.txt---global # https://git-scm.com/docs/git-config#Documentation/git-config.txt---global
home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore [ "checkLinkTargets" ] '' home.activation.removeExistingGitconfig = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
rm -f ~/.gitconfig rm -f ~/.gitconfig
''; '';
+1 -1
View File
@@ -1,4 +1,4 @@
{ ... }: { {...}: {
programs.nushell = { programs.nushell = {
enable = true; enable = true;
configFile.source = ./config.nu; configFile.source = ./config.nu;
+1 -1
View File
@@ -1,4 +1,4 @@
{ ... }: { {...}: {
programs.starship = { programs.starship = {
enable = true; enable = true;
+4 -7
View File
@@ -1,15 +1,12 @@
{ pkgs, ... }: {pkgs, ...}: let
let
buildTmuxPlugin = pkgs.tmuxPlugins.mkTmuxPlugin; buildTmuxPlugin = pkgs.tmuxPlugins.mkTmuxPlugin;
in in {
{
draculaTheme = buildTmuxPlugin { draculaTheme = buildTmuxPlugin {
pluginName = "dracula"; pluginName = "dracula";
version = "v2.2.0"; version = "v2.2.0";
src = builtins.fetchTarball { src = builtins.fetchTarball {
name = "dracula-tmux-v2.2.0"; name = "dracula-tmux-v2.2.0";
url = "https://github.com/dracula/tmux/archive/refs/tags/v2.2.0.tar.gz"; url = "https://github.com/dracula/tmux/archive/refs/tags/v2.2.0.tar.gz";
sha256 = "sha256:0v2k994yy4xx2iw8qxg7qphw46gq2qmg496i3a3h9b6jgwxqm7zn"; sha256 = "sha256:0v2k994yy4xx2iw8qxg7qphw46gq2qmg496i3a3h9b6jgwxqm7zn";
}; };
}; };
+6 -5
View File
@@ -1,9 +1,10 @@
{ config, pkgs, ... }:
let
plugins = pkgs.tmuxPlugins // pkgs.callPackage ./custom-plugins.nix {};
in
{ {
config,
pkgs,
...
}: let
plugins = pkgs.tmuxPlugins // pkgs.callPackage ./custom-plugins.nix {};
in {
programs.tmux = { programs.tmux = {
enable = true; enable = true;
shell = "${pkgs.nushell}/bin/nu"; shell = "${pkgs.nushell}/bin/nu";
+1 -3
View File
@@ -1,6 +1,4 @@
{ ... }: {...}: {
{
programs.zellij = { programs.zellij = {
enable = true; enable = true;
}; };
+1 -3
View File
@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
########################################################################## ##########################################################################
# #
# MacOS specific home configuration # MacOS specific home configuration
+3 -5
View File
@@ -1,6 +1,4 @@
{ ... }: { username, ... }: {
{
imports = [ imports = [
../base/desktop ../base/desktop
@@ -12,9 +10,9 @@
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = { home = {
username = "ryan"; username = username;
# set homeDirectory make build fail # set homeDirectory make build fail
homeDirectory = "/Users/ryan"; homeDirectory = "/Users/${username}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
+1 -1
View File
@@ -1,4 +1,4 @@
{ config, ... }: { {config, ...}: {
# nix-darwin do not set PATH for nushell! so we need to do it manually # nix-darwin do not set PATH for nushell! so we need to do it manually
# this is a workaround to add nix's PATH to nushell # this is a workaround to add nix's PATH to nushell
programs.nushell.extraConfig = '' programs.nushell.extraConfig = ''
+5 -3
View File
@@ -1,8 +1,10 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
# remove existing rime data (squirrel) # remove existing rime data (squirrel)
home.activation.removeExistingRimeData = lib.hm.dag.entryBefore [ "checkLinkTargets" ] '' home.activation.removeExistingRimeData = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
rm -rf "~/Library/Rime/build/flypy.prism.bin" rm -rf "~/Library/Rime/build/flypy.prism.bin"
''; '';
+2 -5
View File
@@ -1,11 +1,8 @@
{ config, ... }: {config, ...}: let
let
d = config.xdg.dataHome; d = config.xdg.dataHome;
c = config.xdg.configHome; c = config.xdg.configHome;
cache = config.xdg.cacheHome; cache = config.xdg.cacheHome;
in in rec {
rec {
# add environment variables # add environment variables
systemd.user.sessionVariables = { systemd.user.sessionVariables = {
# clean up ~ # clean up ~
+1 -5
View File
@@ -1,7 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
# Linux Only Packages, not available on Darwin # Linux Only Packages, not available on Darwin
home.packages = with pkgs; [ home.packages = with pkgs; [
btop # replacement of htop/nmon btop # replacement of htop/nmon
@@ -42,5 +39,4 @@
services = { services = {
# syncthing.enable = true; # syncthing.enable = true;
}; };
} }
+4 -9
View File
@@ -1,6 +1,4 @@
{ ... }: { username, ... }: {
{
imports = [ imports = [
../base/desktop ../base/desktop
@@ -13,12 +11,9 @@
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = let home = {
name = "ryan"; username = username;
in homeDirectory = "/home/${username}";
{
username = name;
homeDirectory = "/home/${name}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
+5 -10
View File
@@ -1,6 +1,4 @@
{ ... }: { username, ... }: {
{
imports = [ imports = [
../base/desktop ../base/desktop
@@ -9,16 +7,13 @@
./desktop ./desktop
./i3 ./i3
]; ];
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = let home = {
name = "ryan"; username = username;
in homeDirectory = "/home/${username}";
{
username = name;
homeDirectory = "/home/${name}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
+1 -2
View File
@@ -1,5 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
home.packages = with pkgs; [ home.packages = with pkgs; [
# creative # creative
# blender # 3d modeling # blender # 3d modeling
+2 -3
View File
@@ -1,5 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
imports = [ imports = [
./creative.nix ./creative.nix
./immutable-file.nix ./immutable-file.nix
@@ -10,7 +9,7 @@
home.packages = with pkgs; [ home.packages = with pkgs; [
# GUI apps # GUI apps
insomnia # REST client insomnia # REST client
wireshark # network analyzer wireshark # network analyzer
# e-book viewer(.epub/.mobi/...) # e-book viewer(.epub/.mobi/...)
+20 -19
View File
@@ -1,9 +1,9 @@
{ config {
, lib config,
, pkgs lib,
, ... pkgs,
...
}: }:
############################################################################################## ##############################################################################################
# #
# Provide a option `home.immutable-file`, it works like `home.file` but make the generated file immutable. # Provide a option `home.immutable-file`, it works like `home.file` but make the generated file immutable.
@@ -16,11 +16,9 @@
# TODO not used yet, need to test it. # TODO not used yet, need to test it.
# #
############################################################################################## ##############################################################################################
with lib; let
with lib;
let
cfg = config.home.immutable-file; cfg = config.home.immutable-file;
immutableFileOpts = { ... }: { immutableFileOpts = {...}: {
options = { options = {
src = mkOption { src = mkOption {
type = types.path; type = types.path;
@@ -44,21 +42,24 @@ let
sudo cp $2 $1 sudo cp $2 $1
sudo chattr +i $1 sudo chattr +i $1
''; '';
in in {
{
options.home.immutable-file = mkOption { options.home.immutable-file = mkOption {
type = with types; attrsOf (submodule immutableFileOpts); type = with types; attrsOf (submodule immutableFileOpts);
default = { }; default = {};
}; };
config = mkIf (cfg != { }) { config = mkIf (cfg != {}) {
home.activation = mapAttrs' home.activation =
(name: { src, dst }: mapAttrs'
(name: {
src,
dst,
}:
nameValuePair nameValuePair
"make-immutable-${name}" "make-immutable-${name}"
(lib.hm.dag.entryAfter [ "writeBoundary" ] '' (lib.hm.dag.entryAfter ["writeBoundary"] ''
${mkImmutableFile} ${dst} ${src} ${mkImmutableFile} ${dst} ${src}
'')) ''))
cfg; cfg;
}; };
} }
+6 -5
View File
@@ -1,6 +1,7 @@
{ pkgs {
, config pkgs,
, ... config,
...
}: }:
# media - control and enjoy audio/video # media - control and enjoy audio/video
{ {
@@ -23,8 +24,8 @@
programs = { programs = {
mpv = { mpv = {
enable = true; enable = true;
defaultProfiles = [ "gpu-hq" ]; defaultProfiles = ["gpu-hq"];
scripts = [ pkgs.mpvScripts.mpris ]; scripts = [pkgs.mpvScripts.mpris];
}; };
}; };
+1 -3
View File
@@ -1,6 +1,4 @@
{ pkgs {pkgs, ...}: {
, ...
}: {
programs.ssh = { programs.ssh = {
enable = true; enable = true;
+50 -51
View File
@@ -2,8 +2,11 @@
# It's a bunch of specifications from freedesktop.org intended to standardize desktops and # It's a bunch of specifications from freedesktop.org intended to standardize desktops and
# other GUI applications on various systems (primarily Unix-like) to be interoperable: # other GUI applications on various systems (primarily Unix-like) to be interoperable:
# https://www.freedesktop.org/wiki/Specifications/ # https://www.freedesktop.org/wiki/Specifications/
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
home.packages = with pkgs; [ home.packages = with pkgs; [
xdg-utils # provides cli tools such as `xdg-mime` `xdg-open` xdg-utils # provides cli tools such as `xdg-mime` `xdg-open`
xdg-user-dirs xdg-user-dirs
@@ -22,61 +25,57 @@
# ls /etc/profiles/per-user/ryan/share/applications/ # ls /etc/profiles/per-user/ryan/share/applications/
mimeApps = { mimeApps = {
enable = true; enable = true;
defaultApplications = defaultApplications = let
let browser = ["firefox.desktop"];
browser = [ "firefox.desktop" ]; in {
in "application/json" = browser;
{ "application/pdf" = browser; # TODO: pdf viewer
"application/json" = browser;
"application/pdf" = browser; # TODO: pdf viewer
"text/html" = browser; "text/html" = browser;
"text/xml" = browser; "text/xml" = browser;
"application/xml" = browser; "application/xml" = browser;
"application/xhtml+xml" = browser; "application/xhtml+xml" = browser;
"application/xhtml_xml" = browser; "application/xhtml_xml" = browser;
"application/rdf+xml" = browser; "application/rdf+xml" = browser;
"application/rss+xml" = browser; "application/rss+xml" = browser;
"application/x-extension-htm" = browser; "application/x-extension-htm" = browser;
"application/x-extension-html" = browser; "application/x-extension-html" = browser;
"application/x-extension-shtml" = browser; "application/x-extension-shtml" = browser;
"application/x-extension-xht" = browser; "application/x-extension-xht" = browser;
"application/x-extension-xhtml" = browser; "application/x-extension-xhtml" = browser;
"x-scheme-handler/about" = browser; "x-scheme-handler/about" = browser;
"x-scheme-handler/ftp" = browser; "x-scheme-handler/ftp" = browser;
"x-scheme-handler/http" = browser; "x-scheme-handler/http" = browser;
"x-scheme-handler/https" = browser; "x-scheme-handler/https" = browser;
"x-scheme-handler/unknown" = browser; "x-scheme-handler/unknown" = browser;
"x-scheme-handler/discord" = [ "discord.desktop" ]; "x-scheme-handler/discord" = ["discord.desktop"];
"x-scheme-handler/tg" = [ "telegramdesktop.desktop" ]; "x-scheme-handler/tg" = ["telegramdesktop.desktop"];
"audio/*" = [ "mpv.desktop" ]; "audio/*" = ["mpv.desktop"];
"video/*" = [ "mpv.dekstop" ]; "video/*" = ["mpv.dekstop"];
"image/*" = [ "imv.desktop" ]; "image/*" = ["imv.desktop"];
}; };
associations.removed = associations.removed = let
let browser = ["google-chrome.desktop"];
browser = [ "google-chrome.desktop" ]; in {
in "text/html" = browser;
{ "text/xml" = browser;
"text/html" = browser; "application/xml" = browser;
"text/xml" = browser; "application/xhtml+xml" = browser;
"application/xml" = browser; "application/xhtml_xml" = browser;
"application/xhtml+xml" = browser; "application/rdf+xml" = browser;
"application/xhtml_xml" = browser; "application/rss+xml" = browser;
"application/rdf+xml" = browser; "image/gif" = browser;
"application/rss+xml" = browser; "image/jpeg" = browser;
"image/gif" = browser; "image/png" = browser;
"image/jpeg" = browser; "image/webp" = browser;
"image/png" = browser; "x-scheme-handler/http" = browser;
"image/webp" = browser; "x-scheme-handler/https" = browser;
"x-scheme-handler/http" = browser; "application/pdf" = browser;
"x-scheme-handler/https" = browser; };
"application/pdf" = browser;
};
}; };
userDirs = { userDirs = {
+7 -3
View File
@@ -1,12 +1,16 @@
{ pkgs, config, lib, ... }: { {
pkgs,
config,
lib,
...
}: {
home.file.".config/fcitx5/profile".source = ./profile; home.file.".config/fcitx5/profile".source = ./profile;
home.file.".config/fcitx5/profile-bak".source = ./profile; # used for backup home.file.".config/fcitx5/profile-bak".source = ./profile; # used for backup
# every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile file, # every time fcitx5 switch input method, it will modify ~/.config/fcitx5/profile file,
# which will override my config managed by home-manager # which will override my config managed by home-manager
# so we need to remove it before everytime we rebuild the config # so we need to remove it before everytime we rebuild the config
home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore [ "checkLinkTargets" ] '' home.activation.removeExistingFcitx5Profile = lib.hm.dag.entryBefore ["checkLinkTargets"] ''
rm -f "${config.xdg.configHome}/fcitx5/profile" rm -f "${config.xdg.configHome}/fcitx5/profile"
''; '';
+1 -4
View File
@@ -1,5 +1,4 @@
{ pkgs, ...}: {pkgs, ...}: {
{
imports = [ imports = [
./wayland-apps.nix ./wayland-apps.nix
]; ];
@@ -22,7 +21,6 @@
home.file.".gtkrc-2.0".source = ./gtkrc-2.0; home.file.".gtkrc-2.0".source = ./gtkrc-2.0;
home.file.".config/hypr/wallpapers/wallpaper.png".source = ../wallpapers/wallpaper.png; home.file.".config/hypr/wallpapers/wallpaper.png".source = ../wallpapers/wallpaper.png;
# music player - mpd # music player - mpd
home.file.".config/mpd" = { home.file.".config/mpd" = {
source = ./mpd; source = ./mpd;
@@ -58,5 +56,4 @@
package = pkgs.qogir-theme; package = pkgs.qogir-theme;
size = 64; size = 64;
}; };
} }
+1 -6
View File
@@ -1,11 +1,6 @@
{ pkgs {pkgs, ...}: {
, ...
}:
{
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it. # TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
programs = { programs = {
# source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix # source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix
google-chrome = { google-chrome = {
enable = true; enable = true;
+1 -2
View File
@@ -1,5 +1,4 @@
{ pkgs, ...}: {pkgs, ...}: {
{
# i3 window manager's config, based on https://github.com/endeavouros-team/endeavouros-i3wm-setup # i3 window manager's config, based on https://github.com/endeavouros-team/endeavouros-i3wm-setup
imports = [ imports = [
+2 -6
View File
@@ -1,15 +1,11 @@
{ pkgs {pkgs, ...}: {
, ...
}: {
home.packages = with pkgs; [ home.packages = with pkgs; [
firefox firefox
xsel # for clipboard support in x11, required by tmux's clipboard support xsel # for clipboard support in x11, required by tmux's clipboard support
]; ];
# TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it. # TODO vscode & chrome both have wayland support, but they don't work with fcitx5, need to fix it.
programs = { programs = {
# source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix # source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix
google-chrome = { google-chrome = {
enable = true; enable = true;
+4 -9
View File
@@ -1,6 +1,4 @@
{ ... }: { username, ... }: {
{
imports = [ imports = [
../base/server ../base/server
@@ -9,12 +7,9 @@
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = let home = {
name = "ryan"; username = username;
in homeDirectory = "/home/${username}";
{
username = name;
homeDirectory = "/home/${name}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage
+20 -11
View File
@@ -1,25 +1,34 @@
{ ... } @ args: { username, ... } @ args:
############################################################# #############################################################
# #
# Harmonica - my MacBook Pro 2020 13-inch, mainly for business. # Harmonica - my MacBook Pro 2020 13-inch, mainly for business.
# #
############################################################# #############################################################
let let
name = "harmonica"; hostname = "harmonica";
in in {
{
imports = [ imports = [
../../modules/darwin/core.nix ../../modules/darwin
../../modules/darwin/apps.nix
../../secrets/darwin.nix ../../secrets/darwin.nix
]; ];
nixpkgs.overlays = import ../../overlays args; nixpkgs.overlays = import ../../overlays args;
networking.hostName = name; networking.hostName = hostname;
networking.computerName = name; networking.computerName = hostname;
system.defaults.smb.NetBIOSName = name; system.defaults.smb.NetBIOSName = hostname;
# Define a user account. Don't forget to set a password with passwd.
users.users."${username}" = {
home = "/Users/${username}";
description = username;
# set user's default shell back to zsh
# `chsh -s /bin/zsh`
# DO NOT change the system's default shell to nushell! it will break some apps!
# It's better to change only starship/alacritty/vscode's shell to nushell!
};
nix.settings.trusted-users = [username];
} }
+7 -5
View File
@@ -1,8 +1,12 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
username,
...
}: {
# mount a smb/cifs share # mount a smb/cifs share
fileSystems."/home/ryan/SMB-Downloads" = { fileSystems."/home/${username}/SMB-Downloads" = {
device = "//192.168.5.194/Downloads"; device = "//192.168.5.194/Downloads";
fsType = "cifs"; fsType = "cifs";
options = [ options = [
@@ -10,5 +14,3 @@
]; ];
}; };
} }
+10 -11
View File
@@ -1,11 +1,9 @@
{ config, ... } @ args: {config, ...} @ args:
############################################################# #############################################################
# #
# Ai - my main computer, with NixOS + I5-13600KF + RTX 4090 GPU, for gaming & daily use. # Ai - my main computer, with NixOS + I5-13600KF + RTX 4090 GPU, for gaming & daily use.
# #
############################################################# #############################################################
{ {
imports = [ imports = [
./cifs-mount.nix ./cifs-mount.nix
@@ -24,7 +22,7 @@
nixpkgs.overlays = import ../../../overlays args; nixpkgs.overlays = import ../../../overlays args;
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation. # Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ]; boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"];
# supported fil systems, so we can mount any removable disks with these filesystems # supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [ boot.supportedFilesystems = [
"ext4" "ext4"
@@ -60,10 +58,12 @@
enableIPv6 = false; # disable ipv6 enableIPv6 = false; # disable ipv6
interfaces.enp5s0 = { interfaces.enp5s0 = {
useDHCP = false; useDHCP = false;
ipv4.addresses = [{ ipv4.addresses = [
address = "192.168.5.100"; {
prefixLength = 24; address = "192.168.5.100";
}]; prefixLength = 24;
}
];
}; };
defaultGateway = "192.168.5.201"; defaultGateway = "192.168.5.201";
nameservers = [ nameservers = [
@@ -75,13 +75,13 @@
virtualisation.docker.storageDriver = "btrfs"; virtualisation.docker.storageDriver = "btrfs";
# for Nvidia GPU # for Nvidia GPU
services.xserver.videoDrivers = [ "nvidia" ]; # will install nvidia-vaapi-driver by default services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default
hardware.nvidia = { hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable; package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true; modesetting.enable = true;
powerManagement.enable = true; powerManagement.enable = true;
}; };
virtualisation.docker.enableNvidia = true; # for nvidia-docker virtualisation.docker.enableNvidia = true; # for nvidia-docker
hardware.opengl = { hardware.opengl = {
enable = true; enable = true;
@@ -98,5 +98,4 @@
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
} }
+23 -23
View File
@@ -1,34 +1,34 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{ {
imports = config,
[ lib,
(modulesPath + "/installer/scan/not-detected.nix") pkgs,
]; modulesPath,
...
}: {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = ["xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod"];
boot.initrd.kernelModules = [ ]; boot.initrd.kernelModules = [];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = ["kvm-intel"];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/231466f6-cdf3-40e1-b9d2-6b4e8d10a4d3";
device = "/dev/disk/by-uuid/231466f6-cdf3-40e1-b9d2-6b4e8d10a4d3"; fsType = "btrfs";
fsType = "btrfs"; options = ["subvol=@"];
options = [ "subvol=@" ]; };
};
fileSystems."/boot/efi" = fileSystems."/boot/efi" = {
{ device = "/dev/disk/by-uuid/87ED-8B2E";
device = "/dev/disk/by-uuid/87ED-8B2E"; fsType = "vfat";
fsType = "vfat"; };
};
swapDevices = swapDevices = [{device = "/dev/disk/by-uuid/17391ca0-8cdb-4598-a40b-fd9548fd9b37";}];
[{ device = "/dev/disk/by-uuid/17391ca0-8cdb-4598-a40b-fd9548fd9b37"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's # (the default) this is the recommended approach. When using systemd-networkd it's
+8 -10
View File
@@ -1,11 +1,9 @@
{ ... } @args: {...} @ args:
############################################################# #############################################################
# #
# Aquamarine - A NixOS VM running on Proxmox # Aquamarine - A NixOS VM running on Proxmox
# #
############################################################# #############################################################
{ {
imports = [ imports = [
{ {
@@ -21,9 +19,8 @@
nixpkgs.overlays = import ../../../overlays args; nixpkgs.overlays = import ../../../overlays args;
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation. # Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ]; boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"];
# supported fil systems, so we can mount any removable disks with these filesystems # supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [ boot.supportedFilesystems = [
"ext4" "ext4"
@@ -48,10 +45,12 @@
networkmanager.enable = true; networkmanager.enable = true;
interfaces.ens18 = { interfaces.ens18 = {
useDHCP = false; useDHCP = false;
ipv4.addresses = [{ ipv4.addresses = [
address = "192.168.5.101"; {
prefixLength = 24; address = "192.168.5.101";
}]; prefixLength = 24;
}
];
}; };
defaultGateway = "192.168.5.201"; defaultGateway = "192.168.5.201";
nameservers = [ nameservers = [
@@ -67,5 +66,4 @@
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
} }
+8 -10
View File
@@ -1,11 +1,9 @@
{ ... } @args: {...} @ args:
############################################################# #############################################################
# #
# Kana - a NixOS VM running on Proxmox # Kana - a NixOS VM running on Proxmox
# #
############################################################# #############################################################
{ {
imports = [ imports = [
{ {
@@ -21,9 +19,8 @@
nixpkgs.overlays = import ../../../overlays args; nixpkgs.overlays = import ../../../overlays args;
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation. # Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ]; boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"];
# supported fil systems, so we can mount any removable disks with these filesystems # supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [ boot.supportedFilesystems = [
"ext4" "ext4"
@@ -48,10 +45,12 @@
networkmanager.enable = true; networkmanager.enable = true;
interfaces.ens18 = { interfaces.ens18 = {
useDHCP = false; useDHCP = false;
ipv4.addresses = [{ ipv4.addresses = [
address = "192.168.5.103"; {
prefixLength = 24; address = "192.168.5.103";
}]; prefixLength = 24;
}
];
}; };
defaultGateway = "192.168.5.201"; defaultGateway = "192.168.5.201";
nameservers = [ nameservers = [
@@ -67,5 +66,4 @@
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment? system.stateVersion = "23.05"; # Did you read the comment?
} }
+8 -12
View File
@@ -1,13 +1,9 @@
{ ... } @args: {...} @ args:
############################################################# #############################################################
# #
# Ruby - a NixOS VM running on Proxmox # Ruby - a NixOS VM running on Proxmox
# #
############################################################# #############################################################
{ {
imports = [ imports = [
{ {
@@ -23,9 +19,8 @@
nixpkgs.overlays = import ../../../overlays args; nixpkgs.overlays = import ../../../overlays args;
# Enable binfmt emulation of aarch64-linux, this is required for cross compilation. # Enable binfmt emulation of aarch64-linux, this is required for cross compilation.
boot.binfmt.emulatedSystems = [ "aarch64-linux" "riscv64-linux" ]; boot.binfmt.emulatedSystems = ["aarch64-linux" "riscv64-linux"];
# supported fil systems, so we can mount any removable disks with these filesystems # supported fil systems, so we can mount any removable disks with these filesystems
boot.supportedFilesystems = [ boot.supportedFilesystems = [
"ext4" "ext4"
@@ -50,10 +45,12 @@
networkmanager.enable = true; networkmanager.enable = true;
interfaces.ens18 = { interfaces.ens18 = {
useDHCP = false; useDHCP = false;
ipv4.addresses = [{ ipv4.addresses = [
address = "192.168.5.102"; {
prefixLength = 24; address = "192.168.5.102";
}]; prefixLength = 24;
}
];
}; };
defaultGateway = "192.168.5.201"; defaultGateway = "192.168.5.201";
nameservers = [ nameservers = [
@@ -69,5 +66,4 @@
# Before changing this value read the documentation for this option # Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.05"; # Did you read the comment? system.stateVersion = "23.05"; # Did you read the comment?
} }
+25
View File
@@ -0,0 +1,25 @@
{
nix-darwin,
home-manager,
system,
specialArgs,
darwin-modules,
home-module,
}: let
username = specialArgs.username;
in
nix-darwin.lib.darwinSystem {
inherit system specialArgs;
modules =
darwin-modules
++ [
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users."${username}" = home-module;
}
];
}
+35
View File
@@ -0,0 +1,35 @@
{
nixpkgs,
home-manager,
nixos-generators,
system,
specialArgs,
nixos-modules,
home-module,
}: let
username = specialArgs.username;
in
nixpkgs.lib.nixosSystem {
inherit system specialArgs;
modules =
nixos-modules
++ [
nixos-generators.nixosModules.all-formats
{
# formatConfigs.iso = {config, ...}: {};
formatConfigs.proxmox = {config, ...}: {
# custom proxmox's image name
proxmox.qemuConf.name = "${config.networking.hostName}-nixos-${config.system.nixos.label}";
};
}
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users."${username}" = home-module;
}
];
}
+50 -153
View File
@@ -1,140 +1,35 @@
{ pkgs, ...}: { {pkgs, ...}: {
########################################################################## ##########################################################################
# #
# MacOS specific nix-darwin configuration # Install all apps and packages here.
# #
# Nix is not well supported on macOS, I met some strange bug recently. # NOTE: Your can find all available options in:
# So install apps using [homebrew](https://daiderd.com/nix-darwin/manual/index.html#opt-homebrew.enable) here. # https://daiderd.com/nix-darwin/manual/index.html
#
# TODO Fell free to modify this file to fit your needs.
# #
########################################################################## ##########################################################################
system = { # Install packages from nix's official package repository.
#
# The packages installed here are available to all users, and are reproducible across machines, and are rollbackable.
# But on macOS, it's less stable than homebrew.
#
# Related Discussion: https://discourse.nixos.org/t/darwin-again/29331
environment.systemPackages = with pkgs; [
neovim
git
nushell # my custom shell
];
environment.variables.EDITOR = "nvim";
# activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`. # Create /etc/zshrc that loads the nix-darwin environment.
activationScripts.postUserActivation.text = '' # this is required if you want to use darwin's default shell - zsh
# activateSettings -u will reload the settings from the database and apply them to the current session, programs.zsh.enable = true;
# so we do not need to logout and login again to make the changes take effect. environment.shells = [
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u pkgs.zsh
''; pkgs.nushell # my custom shell
];
defaults = {
menuExtraClock.Show24Hour = true; # show 24 hour clock
# customize dock
dock = {
autohide = true;
show-recents = false; # disable recent apps
# customize Hot Corners(触发角, 鼠标移动到屏幕角落时触发的动作)
wvous-tl-corner = 2; # top-left - Mission Control
wvous-tr-corner = 13; # top-right - Lock Screen
wvous-bl-corner = 3; # bottom-left - Application Windows
wvous-br-corner = 4; # bottom-right - Desktop
};
# customize finder
finder = {
_FXShowPosixPathInTitle = true; # show full path in finder title
AppleShowAllExtensions = true; # show all file extensions
FXEnableExtensionChangeWarning = false; # disable warning when changing file extension
QuitMenuItem = true; # enable quit menu item
ShowPathbar = true; # show path bar
ShowStatusBar = true; # show status bar
};
# customize trackpad
trackpad = {
# tap - 轻触触摸板, click - 点击触摸板
Clicking = true; # enable tap to click(轻触触摸板相当于点击)
TrackpadRightClick = true; # enable two finger right click
TrackpadThreeFingerDrag = true; # enable three finger drag
};
# customize macOS
NSGlobalDomain = {
# `defaults read NSGlobalDomain "xxx"`
"com.apple.swipescrolldirection" = true; # enable natural scrolling(default to true)
"com.apple.sound.beep.feedback" = 0; # disable beep sound when pressing volume up/down key
AppleInterfaceStyle = "Dark"; # dark mode
AppleKeyboardUIMode = 3; # Mode 3 enables full keyboard control.
ApplePressAndHoldEnabled = true; # enable press and hold
# If you press and hold certain keyboard keys when in a text area, the keys character begins to repeat.
# This is very useful for vim users, they use `hjkl` to move cursor.
# sets how long it takes before it starts repeating.
InitialKeyRepeat = 15; # normal minimum is 15 (225 ms), maximum is 120 (1800 ms)
# sets how fast it repeats once it starts.
KeyRepeat = 3; # normal minimum is 2 (30 ms), maximum is 120 (1800 ms)
NSAutomaticCapitalizationEnabled = false; # disable auto capitalization(自动大写)
NSAutomaticDashSubstitutionEnabled = false; # disable auto dash substitution(智能破折号替换)
NSAutomaticPeriodSubstitutionEnabled = false; # disable auto period substitution(智能句号替换)
NSAutomaticQuoteSubstitutionEnabled = false; # disable auto quote substitution(智能引号替换)
NSAutomaticSpellingCorrectionEnabled = false; # disable auto spelling correction(自动拼写检查)
NSNavPanelExpandedStateForSaveMode = true; # expand save panel by default(保存文件时的路径选择/文件名输入页)
NSNavPanelExpandedStateForSaveMode2 = true;
};
# customize settings that not supported by nix-darwin directly
CustomUserPreferences = {
NSGlobalDomain = {
# Add a context menu item for showing the Web Inspector in web views
WebKitDeveloperExtras = true;
};
"com.apple.finder" = {
ShowExternalHardDrivesOnDesktop = true;
ShowHardDrivesOnDesktop = true;
ShowMountedServersOnDesktop = true;
ShowRemovableMediaOnDesktop = true;
_FXSortFoldersFirst = true;
# When performing a search, search the current folder by default
FXDefaultSearchScope = "SCcf";
};
"com.apple.desktopservices" = {
# Avoid creating .DS_Store files on network or USB volumes
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.screensaver" = {
# Require password immediately after sleep or screen saver begins
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.screencapture" = {
location = "~/Desktop";
type = "png";
};
"com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false;
};
# Prevent Photos from opening automatically when devices are plugged in
"com.apple.ImageCapture".disableHotPlug = true;
};
loginwindow = {
GuestEnabled = false; # disable guest user
SHOWFULLNAME = true; # show full name in login window
};
};
# keyboard settings is not very useful on macOS
# the most important thing is to remap option key to alt key globally,
# but it's not supported by macOS yet.
keyboard = {
enableKeyMapping = true; # enable key mapping so that we can use `option` as `control`
# NOTE: do NOT support remap capslock to both control and escape at the same time
remapCapsLockToControl = false; # remap caps lock to control, useful for emac users
remapCapsLockToEscape = true; # remap caps lock to escape, useful for vim users
# swap left command and left alt
# so it matches common keyboard layout: `ctrl | command | alt`
#
# disabled, caused only problems!
swapLeftCommandAndLeftAlt = false;
};
};
# Homebrew Mirror # Homebrew Mirror
environment.variables = { environment.variables = {
@@ -145,12 +40,11 @@
HOMEBREW_PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple"; HOMEBREW_PIP_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple";
}; };
# homebrew need to be installed manually, see https://brew.sh # homebrew need to be installed manually, see https://brew.sh
homebrew = { homebrew = {
# TODO Homebrew install takes a long time, # TODO Homebrew install takes a long time,
# So only enable this when you make changes. # So only enable this when you make changes.
enable = false; enable = true;
onActivation = { onActivation = {
autoUpdate = false; autoUpdate = false;
@@ -166,7 +60,7 @@
# Xcode = 497799835; # Xcode = 497799835;
Wechat = 836500024; Wechat = 836500024;
QQ = 451108668; QQ = 451108668;
WeCom = 1189898970; # Wechat for Work WeCom = 1189898970; # Wechat for Work
TecentMetting = 1484048379; TecentMetting = 1484048379;
NeteaseCloudMusic = 944848654; NeteaseCloudMusic = 944848654;
QQMusic = 595615424; QQMusic = 595615424;
@@ -184,22 +78,25 @@
brews = [ brews = [
# `brew install` # `brew install`
"wget" # download tool "wget" # download tool
"curl" # no not install curl via nixpkgs, it's not working well on macOS! "curl" # no not install curl via nixpkgs, it's not working well on macOS!
"aria2" # download tool "aria2" # download tool
"httpie" # http client "httpie" # http client
"wireguard-tools" # wireguard "wireguard-tools" # wireguard
# Usage: # Usage:
# https://github.com/tailscale/tailscale/wiki/Tailscaled-on-macOS#run-the-tailscaled-daemon # https://github.com/tailscale/tailscale/wiki/Tailscaled-on-macOS#run-the-tailscaled-daemon
# 1. `sudo tailscaled install-system-daemon` # 1. `sudo tailscaled install-system-daemon`
# 2. `tailscale up --accept-routes` # 2. `tailscale up --accept-routes`
"tailscale" # tailscale "tailscale" # tailscale
# https://github.com/rgcr/m-cli
"m-cli" #  Swiss Army Knife for macOS
]; ];
# `brew install --cask` # `brew install --cask`
casks = [ casks = [
"squirrel" # input method for Chinese, rime-squirrel "squirrel" # input method for Chinese, rime-squirrel
"firefox" "firefox"
"google-chrome" "google-chrome"
@@ -213,20 +110,20 @@
"microsoft-remote-desktop" "microsoft-remote-desktop"
# "anki" # "anki"
"clashx" # proxy tool "clashx" # proxy tool
"iina" # video player "iina" # video player
"openinterminal-lite" # open current folder in terminal "openinterminal-lite" # open current folder in terminal
"syncthing" # file sync "syncthing" # file sync
"raycast" # (HotKey: alt/option + space)search, caculate and run scripts(with many plugins) "raycast" # (HotKey: alt/option + space)search, caculate and run scripts(with many plugins)
"iglance" # beautiful system monitor "iglance" # beautiful system monitor
"eudic" # 欧路词典 "eudic" # 欧路词典
# "reaper" # audio editor # "reaper" # audio editor
# Development # Development
"insomnia" # REST client "insomnia" # REST client
"wireshark" # network analyzer "wireshark" # network analyzer
"jdk-mission-control" # Java Mission Control "jdk-mission-control" # Java Mission Control
"google-cloud-sdk" # Google Cloud SDK "google-cloud-sdk" # Google Cloud SDK
]; ];
}; };
} }
-102
View File
@@ -1,102 +0,0 @@
{ pkgs, lib, ... }:
{
###################################################################################
#
# Core configuration for nix-darwin
#
# All the configuration options are documented here:
# https://daiderd.com/nix-darwin/manual/index.html#sec-options
#
###################################################################################
# enable flakes globally
nix.settings.experimental-features = [ "nix-command" "flakes" ];
nix.settings.trusted-users = ["ryan"];
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Use this instead of services.nix-daemon.enable if you
# don't wan't the daemon service to be managed for you.
# nix.useDaemon = true;
nix.package = pkgs.nix;
programs.nix-index.enable = true;
# boot.loader.grub.configurationLimit = 10;
# do garbage collection weekly to keep disk usage low
nix.gc = {
automatic = lib.mkDefault true;
options = lib.mkDefault "--delete-older-than 1w";
};
# Manual optimise storage: nix-store --optimise
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
nix.settings.auto-optimise-store = true;
# Add ability to used TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true;
# Set your time zone.
# comment this due to the issue:
# https://github.com/LnL7/nix-darwin/issues/359
# time.timeZone = "Asia/shanghai";
# Apps
# `home-manager` currently has issues adding them to `~/Applications`
# Issue: https://github.com/nix-community/home-manager/issues/1341
environment.systemPackages = with pkgs; [
neovim
git
nushell # my custom shell
];
environment.variables.EDITOR = "nvim";
# Fonts
fonts = {
# use fonts specified by user rather than default ones
fontDir.enable = true;
fonts = with pkgs; [
# icon fonts
material-design-icons
font-awesome
# nerdfonts
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
];
};
# Define a user account. Don't forget to set a password with passwd.
users.users.ryan = {
home = "/Users/ryan";
description = "ryan";
# set user's default shell back to zsh
# `chsh -s /bin/zsh`
# DO NOT change the system's default shell to nushell! it will break some apps!
# It's better to change only starship/alacritty/vscode's shell to nushell!
};
# Create /etc/zshrc that loads the nix-darwin environment.
# this is required if you want to use darwin's default shell - zsh
programs.zsh.enable = true;
environment.shells = [
pkgs.zsh
pkgs.nushell # my custom shell
];
}
+7
View File
@@ -0,0 +1,7 @@
{
imports = [
./apps.nix
./nix-core.nix
./system.nix
];
}
+41
View File
@@ -0,0 +1,41 @@
{
pkgs,
lib,
...
}: {
###################################################################################
#
# Core configuration for nix-darwin
#
# All the configuration options are documented here:
# https://daiderd.com/nix-darwin/manual/index.html#sec-options
#
###################################################################################
# enable flakes globally
nix.settings.experimental-features = ["nix-command" "flakes"];
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
# Use this instead of services.nix-daemon.enable if you
# don't wan't the daemon service to be managed for you.
# nix.useDaemon = true;
nix.package = pkgs.nix;
programs.nix-index.enable = true;
# boot.loader.grub.configurationLimit = 10;
# do garbage collection weekly to keep disk usage low
nix.gc = {
automatic = lib.mkDefault true;
options = lib.mkDefault "--delete-older-than 1w";
};
# Manual optimise storage: nix-store --optimise
# https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-auto-optimise-store
nix.settings.auto-optimise-store = true;
}
+165
View File
@@ -0,0 +1,165 @@
{pkgs, ...}:
###################################################################################
#
# macOS's System configuration
#
# All the configuration options are documented here:
# https://daiderd.com/nix-darwin/manual/index.html#sec-options
#
###################################################################################
{
# Add ability to used TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true;
system = {
# activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`.
activationScripts.postUserActivation.text = ''
# activateSettings -u will reload the settings from the database and apply them to the current session,
# so we do not need to logout and login again to make the changes take effect.
/System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u
'';
defaults = {
menuExtraClock.Show24Hour = true; # show 24 hour clock
# customize dock
dock = {
autohide = true;
show-recents = false; # disable recent apps
# customize Hot Corners(触发角, 鼠标移动到屏幕角落时触发的动作)
wvous-tl-corner = 2; # top-left - Mission Control
wvous-tr-corner = 13; # top-right - Lock Screen
wvous-bl-corner = 3; # bottom-left - Application Windows
wvous-br-corner = 4; # bottom-right - Desktop
};
# customize finder
finder = {
_FXShowPosixPathInTitle = true; # show full path in finder title
AppleShowAllExtensions = true; # show all file extensions
FXEnableExtensionChangeWarning = false; # disable warning when changing file extension
QuitMenuItem = true; # enable quit menu item
ShowPathbar = true; # show path bar
ShowStatusBar = true; # show status bar
};
# customize trackpad
trackpad = {
# tap - 轻触触摸板, click - 点击触摸板
Clicking = true; # enable tap to click(轻触触摸板相当于点击)
TrackpadRightClick = true; # enable two finger right click
TrackpadThreeFingerDrag = true; # enable three finger drag
};
# customize macOS
NSGlobalDomain = {
# `defaults read NSGlobalDomain "xxx"`
"com.apple.swipescrolldirection" = true; # enable natural scrolling(default to true)
"com.apple.sound.beep.feedback" = 0; # disable beep sound when pressing volume up/down key
AppleInterfaceStyle = "Dark"; # dark mode
AppleKeyboardUIMode = 3; # Mode 3 enables full keyboard control.
ApplePressAndHoldEnabled = true; # enable press and hold
# If you press and hold certain keyboard keys when in a text area, the keys character begins to repeat.
# This is very useful for vim users, they use `hjkl` to move cursor.
# sets how long it takes before it starts repeating.
InitialKeyRepeat = 15; # normal minimum is 15 (225 ms), maximum is 120 (1800 ms)
# sets how fast it repeats once it starts.
KeyRepeat = 3; # normal minimum is 2 (30 ms), maximum is 120 (1800 ms)
NSAutomaticCapitalizationEnabled = false; # disable auto capitalization(自动大写)
NSAutomaticDashSubstitutionEnabled = false; # disable auto dash substitution(智能破折号替换)
NSAutomaticPeriodSubstitutionEnabled = false; # disable auto period substitution(智能句号替换)
NSAutomaticQuoteSubstitutionEnabled = false; # disable auto quote substitution(智能引号替换)
NSAutomaticSpellingCorrectionEnabled = false; # disable auto spelling correction(自动拼写检查)
NSNavPanelExpandedStateForSaveMode = true; # expand save panel by default(保存文件时的路径选择/文件名输入页)
NSNavPanelExpandedStateForSaveMode2 = true;
};
# customize settings that not supported by nix-darwin directly
CustomUserPreferences = {
NSGlobalDomain = {
# Add a context menu item for showing the Web Inspector in web views
WebKitDeveloperExtras = true;
};
"com.apple.finder" = {
ShowExternalHardDrivesOnDesktop = true;
ShowHardDrivesOnDesktop = true;
ShowMountedServersOnDesktop = true;
ShowRemovableMediaOnDesktop = true;
_FXSortFoldersFirst = true;
# When performing a search, search the current folder by default
FXDefaultSearchScope = "SCcf";
};
"com.apple.desktopservices" = {
# Avoid creating .DS_Store files on network or USB volumes
DSDontWriteNetworkStores = true;
DSDontWriteUSBStores = true;
};
"com.apple.screensaver" = {
# Require password immediately after sleep or screen saver begins
askForPassword = 1;
askForPasswordDelay = 0;
};
"com.apple.screencapture" = {
location = "~/Desktop";
type = "png";
};
"com.apple.AdLib" = {
allowApplePersonalizedAdvertising = false;
};
# Prevent Photos from opening automatically when devices are plugged in
"com.apple.ImageCapture".disableHotPlug = true;
};
loginwindow = {
GuestEnabled = false; # disable guest user
SHOWFULLNAME = true; # show full name in login window
};
};
# keyboard settings is not very useful on macOS
# the most important thing is to remap option key to alt key globally,
# but it's not supported by macOS yet.
keyboard = {
enableKeyMapping = true; # enable key mapping so that we can use `option` as `control`
# NOTE: do NOT support remap capslock to both control and escape at the same time
remapCapsLockToControl = false; # remap caps lock to control, useful for emac users
remapCapsLockToEscape = true; # remap caps lock to escape, useful for vim users
# swap left command and left alt
# so it matches common keyboard layout: `ctrl | command | alt`
#
# disabled, caused only problems!
swapLeftCommandAndLeftAlt = false;
};
};
# Set your time zone.
# comment this due to the issue:
# https://github.com/LnL7/nix-darwin/issues/359
# time.timeZone = "Asia/shanghai";
# Fonts
fonts = {
# use fonts specified by user rather than default ones
fontDir.enable = true;
fonts = with pkgs; [
# icon fonts
material-design-icons
font-awesome
# nerdfonts
(nerdfonts.override {
fonts = [
"FiraCode"
"JetBrainsMono"
"Iosevka"
];
})
];
};
}
+19 -31
View File
@@ -1,6 +1,8 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
################################################################################### ###################################################################################
# #
# NixOS's core configuration suitable for my desktop computer # NixOS's core configuration suitable for my desktop computer
@@ -17,20 +19,6 @@
# Enable CUPS to print documents. # Enable CUPS to print documents.
services.printing.enable = true; services.printing.enable = true;
# DO NOT promote ryan to input password for `nix-store` and `nix-copy-closure`
security.sudo.extraRules = [
{ users = [ "ryan" ];
commands = [
{ command = "/run/current-system/sw/bin/nix-store" ;
options = [ "NOPASSWD" ];
}
{ command = "/run/current-system/sw/bin/nix-copy-closure" ;
options = [ "NOPASSWD" ];
}
];
}
];
# all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts # all fonts are linked to /nix/var/nix/profiles/system/sw/share/X11/fonts
fonts = { fonts = {
# use fonts specified by user rather than default ones # use fonts specified by user rather than default ones
@@ -65,17 +53,17 @@
]; ];
}) })
(pkgs.callPackage ../../fonts/icomoon-feather-icon-font.nix { }) (pkgs.callPackage ../../fonts/icomoon-feather-icon-font.nix {})
]; ];
# user defined fonts # user defined fonts
# the reason there's Noto Color Emoji everywhere is to override DejaVu's # the reason there's Noto Color Emoji everywhere is to override DejaVu's
# B&W emojis that would sometimes show instead of some Color emojis # B&W emojis that would sometimes show instead of some Color emojis
fontconfig.defaultFonts = { fontconfig.defaultFonts = {
serif = [ "Noto Serif" "Noto Color Emoji" ]; serif = ["Noto Serif" "Noto Color Emoji"];
sansSerif = [ "Noto Sans" "Noto Color Emoji" ]; sansSerif = ["Noto Sans" "Noto Color Emoji"];
monospace = [ "JetBrainsMono Nerd Font" "Noto Color Emoji" ]; monospace = ["JetBrainsMono Nerd Font" "Noto Color Emoji"];
emoji = [ "Noto Color Emoji" ]; emoji = ["Noto Color Emoji"];
}; };
}; };
@@ -107,13 +95,14 @@
# $ nix search wget # $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
# python, some times I may need to use python with root permission. # python, some times I may need to use python with root permission.
(python310.withPackages (ps: with ps; [ (python310.withPackages (ps:
ipython with ps; [
pandas ipython
requests pandas
pyquery requests
pyyaml pyquery
])) pyyaml
]))
]; ];
# PipeWire is a new low-level multimedia framework. # PipeWire is a new low-level multimedia framework.
@@ -167,7 +156,6 @@
services.gnome.gnome-keyring.enable = true; services.gnome.gnome-keyring.enable = true;
security.pam.services.greetd.enableGnomeKeyring = true; security.pam.services.greetd.enableGnomeKeyring = true;
# A key remapping daemon for linux. # A key remapping daemon for linux.
# https://github.com/rvaiya/keyd # https://github.com/rvaiya/keyd
services.keyd = { services.keyd = {
@@ -181,14 +169,14 @@
}; };
services = { services = {
dbus.packages = [ pkgs.gcr ]; dbus.packages = [pkgs.gcr];
geoclue2.enable = true; geoclue2.enable = true;
udev.packages = with pkgs; [ udev.packages = with pkgs; [
gnome.gnome-settings-daemon gnome.gnome-settings-daemon
platformio # udev rules for platformio platformio # udev rules for platformio
openocd # required by paltformio, see https://github.com/NixOS/nixpkgs/issues/224895 openocd # required by paltformio, see https://github.com/NixOS/nixpkgs/issues/224895
android-udev-rules android-udev-rules
]; ];
}; };
+16 -12
View File
@@ -1,6 +1,8 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
################################################################################### ###################################################################################
# #
# NixOS's core configuration suitable for all my machines # NixOS's core configuration suitable for all my machines
@@ -22,8 +24,7 @@
nix.settings.auto-optimise-store = true; nix.settings.auto-optimise-store = true;
# enable flakes globally # enable flakes globally
nix.settings.experimental-features = [ "nix-command" "flakes" ]; nix.settings.experimental-features = ["nix-command" "flakes"];
# Allow unfree packages # Allow unfree packages
nixpkgs.config.allowUnfree = lib.mkDefault false; nixpkgs.config.allowUnfree = lib.mkDefault false;
@@ -74,14 +75,17 @@
# create a fhs environment by command `fhs`, so we can run non-nixos packages in nixos! # create a fhs environment by command `fhs`, so we can run non-nixos packages in nixos!
( (
let base = pkgs.appimageTools.defaultFhsEnvArgs; in let
pkgs.buildFHSUserEnv (base // { base = pkgs.appimageTools.defaultFhsEnvArgs;
name = "fhs"; in
targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [ pkgs.pkg-config ]; pkgs.buildFHSUserEnv (base
profile = "export FHS=1"; // {
runScript = "bash"; name = "fhs";
extraOutputsToInstall = [ "dev" ]; targetPkgs = pkgs: (base.targetPkgs pkgs) ++ [pkgs.pkg-config];
}) profile = "export FHS=1";
runScript = "bash";
extraOutputsToInstall = ["dev"];
})
) )
]; ];
+20 -20
View File
@@ -1,6 +1,8 @@
{ config, pkgs, ... }:
{ {
config,
pkgs,
...
}: {
################################################################################### ###################################################################################
# #
# Copy from https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1326957279 # Copy from https://github.com/NixOS/nixpkgs/issues/119433#issuecomment-1326957279
@@ -11,23 +13,21 @@
# #
################################################################################### ###################################################################################
system.fsPackages = [ pkgs.bindfs ]; system.fsPackages = [pkgs.bindfs];
fileSystems = fileSystems = let
let mkRoSymBind = path: {
mkRoSymBind = path: { device = path;
device = path; fsType = "fuse.bindfs";
fsType = "fuse.bindfs"; options = ["ro" "resolve-symlinks" "x-gvfs-hide"];
options = [ "ro" "resolve-symlinks" "x-gvfs-hide" ];
};
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.fonts;
pathsToLink = [ "/share/fonts" ];
};
in
{
# Create an FHS mount to support flatpak host icons/fonts
"/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
"/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
}; };
aggregatedFonts = pkgs.buildEnv {
name = "system-fonts";
paths = config.fonts.fonts;
pathsToLink = ["/share/fonts"];
};
in {
# Create an FHS mount to support flatpak host icons/fonts
"/usr/share/icons" = mkRoSymBind (config.system.path + "/share/icons");
"/usr/share/fonts" = mkRoSymBind (aggregatedFonts + "/share/fonts");
};
} }
+4 -10
View File
@@ -1,8 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
########################################################################################################## ##########################################################################################################
# #
# NixOS's Configuration for Hyprland Window Manager # NixOS's Configuration for Hyprland Window Manager
@@ -13,8 +9,7 @@
# #
########################################################################################################## ##########################################################################################################
environment.pathsToLink = ["/libexec"]; # links /libexec from derivations to /run/current-system/sw
environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw
services.xserver = { services.xserver = {
enable = true; enable = true;
@@ -44,7 +39,6 @@
}; };
programs.light.enable = true; # monitor backlight control programs.light.enable = true; # monitor backlight control
# thunar file manager(part of xfce) related options # thunar file manager(part of xfce) related options
programs.thunar.plugins = with pkgs.xfce; [ programs.thunar.plugins = with pkgs.xfce; [
thunar-archive-plugin thunar-archive-plugin
@@ -74,8 +68,8 @@
yad # a fork of zenity, for creating dialogs yad # a fork of zenity, for creating dialogs
# audio # audio
alsa-utils # provides amixer/alsamixer/... alsa-utils # provides amixer/alsamixer/...
cava # for visualizing audio cava # for visualizing audio
mpd # for playing system sounds mpd # for playing system sounds
mpc-cli # command-line mpd client mpc-cli # command-line mpd client
ncmpcpp # a mpd client with a UI ncmpcpp # a mpd client with a UI
+3 -5
View File
@@ -1,6 +1,4 @@
{ pkgs, ... }: {pkgs, ...}: {
{
#################################################################### ####################################################################
# #
# NixOS's Configuration for I3 Window Manager # NixOS's Configuration for I3 Window Manager
@@ -8,7 +6,7 @@
#################################################################### ####################################################################
# i3 related options # i3 related options
environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw environment.pathsToLink = ["/libexec"]; # links /libexec from derivations to /run/current-system/sw
services.xserver = { services.xserver = {
enable = true; enable = true;
@@ -42,7 +40,7 @@
xorg.xdpyinfo # get screen information xorg.xdpyinfo # get screen information
scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot scrot # minimal screen capture tool, used by i3 blur lock to take a screenshot
sysstat # get system information sysstat # get system information
alsa-utils # provides amixer/alsamixer/... alsa-utils # provides amixer/alsamixer/...
xfce.thunar # xfce4's file manager xfce.thunar # xfce4's file manager
]; ];
+6 -6
View File
@@ -1,7 +1,8 @@
{ lib, pkgs, ... }:
{ {
lib,
pkgs,
...
}: {
################################################################################### ###################################################################################
# #
# Enable Libvirt(QEMU/KVM), install qemu-system-riscv64/qemu-system-loongarch64/...) # Enable Libvirt(QEMU/KVM), install qemu-system-riscv64/qemu-system-loongarch64/...)
@@ -37,12 +38,11 @@
qemu_full qemu_full
]; ];
boot.kernelModules = [ "kvm-amd" "kvm-intel" ]; boot.kernelModules = ["kvm-amd" "kvm-intel"];
# Enable nested virsualization, required by security containers and nested vm. # Enable nested virsualization, required by security containers and nested vm.
boot.extraModprobeConfig = "options kvm_intel nested=1"; # for intel cpu boot.extraModprobeConfig = "options kvm_intel nested=1"; # for intel cpu
# boot.extraModprobeConfig = "options kvm_amd nested=1"; # for amd cpu # boot.extraModprobeConfig = "options kvm_amd nested=1"; # for amd cpu
# NixOS VM should enable this: # NixOS VM should enable this:
# services.qemuGuest = { # services.qemuGuest = {
# enable = true; # enable = true;
@@ -1,5 +1,9 @@
{ config, lib, ... }: {
config,
lib,
username,
...
}:
############################################################################## ##############################################################################
# #
# Template for Proxmox's VM, mainly based on: # Template for Proxmox's VM, mainly based on:
@@ -8,17 +12,17 @@
# the url above is used by `nixos-generator` to generate the Proxmox's VMA image file. # the url above is used by `nixos-generator` to generate the Proxmox's VMA image file.
# #
############################################################################## ##############################################################################
{ {
# DO NOT promote ryan to input password for sudo. # DO NOT promote ryan to input password for sudo.
# this is a workaround for the issue of remote deploy: # this is a workaround for the issue of remote deploy:
# https://github.com/NixOS/nixpkgs/issues/118655 # https://github.com/NixOS/nixpkgs/issues/118655
security.sudo.extraRules = [ security.sudo.extraRules = [
{ users = [ "ryan" ]; {
users = [ username ];
commands = [ commands = [
{ command = "ALL" ; {
options = [ "NOPASSWD" ]; command = "ALL";
options = ["NOPASSWD"];
} }
]; ];
} }
@@ -27,7 +31,7 @@
boot = { boot = {
# after resize the disk, it will grow partition automatically. # after resize the disk, it will grow partition automatically.
growPartition = true; growPartition = true;
kernelParams = [ "console=ttyS0" ]; kernelParams = ["console=ttyS0"];
loader.grub = { loader.grub = {
device = "/dev/vda"; device = "/dev/vda";
@@ -36,8 +40,8 @@
efiInstallAsRemovable = false; efiInstallAsRemovable = false;
}; };
loader.timeout = 3; # wait for 3 seconds to select the boot entry loader.timeout = lib.mkForce 3; # wait for 3 seconds to select the boot entry
initrd.availableKernelModules = [ "uas" "virtio_blk" "virtio_pci" ]; initrd.availableKernelModules = ["uas" "virtio_blk" "virtio_pci"];
}; };
fileSystems."/" = { fileSystems."/" = {
@@ -47,7 +51,6 @@
}; };
# we do not have a /boot partition, so do not mount it. # we do not have a /boot partition, so do not mount it.
# it alse had qemu-guest-agent installed by default. # it alse had qemu-guest-agent installed by default.
services.qemuGuest.enable = lib.mkDefault true; services.qemuGuest.enable = lib.mkDefault true;
} }
+58 -59
View File
@@ -1,5 +1,5 @@
{ ... }: { { username, ... }:
{
#################################################################### ####################################################################
# #
# NixOS's Configuration for Remote Building / Distributed Building # NixOS's Configuration for Remote Building / Distributed Building
@@ -8,68 +8,67 @@
# 1. https://github.com/NixOS/nix/issues/7380 # 1. https://github.com/NixOS/nix/issues/7380
# 2. https://nixos.wiki/wiki/Distributed_build # 2. https://nixos.wiki/wiki/Distributed_build
# 3. https://github.com/NixOS/nix/issues/2589 # 3. https://github.com/NixOS/nix/issues/2589
#
#################################################################### ####################################################################
# set local's max-job to 0 to force remote building(disable local building) # set local's max-job to 0 to force remote building(disable local building)
# nix.settings.max-jobs = 0; # nix.settings.max-jobs = 0;
nix.distributedBuilds = true; nix.distributedBuilds = true;
nix.buildMachines = nix.buildMachines = let
let sshUser = username;
sshUser = "ryan"; # ssh key's path on local machine
# ssh key's path on local machine sshKey = "/home/${username}/.ssh/ai-idols";
sshKey = "/home/ryan/.ssh/ai-idols"; systems = [
systems = [ # native arch
# native arch "x86_64-linux"
"x86_64-linux"
# emulated arch using binfmt_misc and qemu-user # emulated arch using binfmt_misc and qemu-user
"aarch64-linux" "aarch64-linux"
"riscv64-linux" "riscv64-linux"
]; ];
# all available system features are poorly documentd here: # all available system features are poorly documentd here:
# https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687 # https://github.com/NixOS/nix/blob/e503ead/src/libstore/globals.hh#L673-L687
supportedFeatures = [ supportedFeatures = [
"benchmark" "benchmark"
"big-parallel" "big-parallel"
"kvm" "kvm"
]; ];
in in [
[ # Nix seems always try to build on the machine remotely
# Nix seems always try to build on the machine remotely # to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high.
# to make use of the local machine's high-performance CPU, do not set remote builder's maxJobs too high. {
{ # some of my remote builders are running NixOS
# some of my remote builders are running NixOS # and has the same sshUser, sshKey, systems, etc.
# and has the same sshUser, sshKey, systems, etc. inherit sshUser sshKey systems supportedFeatures;
inherit sshUser sshKey systems supportedFeatures;
# the hostName should be: # the hostName should be:
# 1. a hostname that can be resolved by DNS # 1. a hostname that can be resolved by DNS
# 2. the ip address of the remote builder # 2. the ip address of the remote builder
# 3. a host alias defined globally in /etc/ssh/ssh_config # 3. a host alias defined globally in /etc/ssh/ssh_config
hostName = "aquamarine"; hostName = "aquamarine";
# remote builder's max-job # remote builder's max-job
maxJobs = 3; maxJobs = 3;
# speedFactor's a signed integer # speedFactor's a signed integer
# but it seems that it's not used by Nix, takes no effect # but it seems that it's not used by Nix, takes no effect
speedFactor = 1; speedFactor = 1;
} }
{ {
inherit sshUser sshKey systems supportedFeatures; inherit sshUser sshKey systems supportedFeatures;
hostName = "ruby"; hostName = "ruby";
maxJobs = 2; maxJobs = 2;
speedFactor = 1; speedFactor = 1;
} }
{ {
inherit sshUser sshKey systems supportedFeatures; inherit sshUser sshKey systems supportedFeatures;
hostName = "kana"; hostName = "kana";
maxJobs = 2; maxJobs = 2;
speedFactor = 1; speedFactor = 1;
} }
]; ];
# optional, useful when the builder has a faster internet connection than yours # optional, useful when the builder has a faster internet connection than yours
nix.extraOptions = '' nix.extraOptions = ''
builders-use-substitutes = true builders-use-substitutes = true
''; '';
# define the host alias for remote builders # define the host alias for remote builders
# this config will be written to /etc/ssh/ssh_config # this config will be written to /etc/ssh/ssh_config
@@ -96,19 +95,19 @@
programs.ssh.knownHosts = { programs.ssh.knownHosts = {
# 星野 愛久愛海, Hoshino Aquamarine # 星野 愛久愛海, Hoshino Aquamarine
aquamarine = { aquamarine = {
hostNames = [ "aquamarine" "192.168.5.101" ]; hostNames = ["aquamarine" "192.168.5.101"];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDnCQXlllHoLX5EvU+t6yP/npsmuxKt0skHVeJashizE"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDnCQXlllHoLX5EvU+t6yP/npsmuxKt0skHVeJashizE";
}; };
# 星野 瑠美衣, Hoshino Rubii # 星野 瑠美衣, Hoshino Rubii
ruby = { ruby = {
hostNames = [ "ruby" "192.168.5.102" ]; hostNames = ["ruby" "192.168.5.102"];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE7n11XxB8B3HjdyAsL3PuLVDZxWCzEOUTJAY8+goQmW"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE7n11XxB8B3HjdyAsL3PuLVDZxWCzEOUTJAY8+goQmW";
}; };
# 有馬 かな, Arima Kana # 有馬 かな, Arima Kana
kana = { kana = {
hostNames = [ "kana" "192.168.5.103" ]; hostNames = ["kana" "192.168.5.103"];
publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ3dDLOZERP1nZfRz3zIeVDm1q2Trer+fWFVvVXrgXM1"; publicKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ3dDLOZERP1nZfRz3zIeVDm1q2Trer+fWFVvVXrgXM1";
}; };
}; };
+26 -9
View File
@@ -1,22 +1,22 @@
{ ... }: { username, ... }:
{ {
nix.settings.trusted-users = ["ryan"]; nix.settings.trusted-users = [username];
users.groups = { users.groups = {
ryan = { }; "${username}" = {};
docker = { }; docker = {};
wireshark = { }; wireshark = {};
}; };
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.ryan = { users.users."${username}" = {
# the hashed password with salt is generated by run `mkpasswd`. # the hashed password with salt is generated by run `mkpasswd`.
hashedPassword = "$y$j9T$YQu5vhlnogjDFDWp9QkPh0$Eu85OiwllqvLg5fzRVMLVHNO7InA3ro8grTJJIepyH1"; hashedPassword = "$y$j9T$YQu5vhlnogjDFDWp9QkPh0$Eu85OiwllqvLg5fzRVMLVHNO7InA3ro8grTJJIepyH1";
home = "/home/ryan"; home = "/home/${username}";
isNormalUser = true; isNormalUser = true;
description = "ryan"; description = username;
extraGroups = [ extraGroups = [
"ryan" username
"users" "users"
"networkmanager" "networkmanager"
"wheel" "wheel"
@@ -29,4 +29,21 @@
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDiipi59EnVbi6bK1bGrcbfEM263wgdNfbrt6VBC1rHx ryan@ai-idols" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDiipi59EnVbi6bK1bGrcbfEM263wgdNfbrt6VBC1rHx ryan@ai-idols"
]; ];
}; };
# DO NOT promote the specified user to input password for `nix-store` and `nix-copy-closure`
security.sudo.extraRules = [
{
users = [username];
commands = [
{
command = "/run/current-system/sw/bin/nix-store";
options = ["NOPASSWD"];
}
{
command = "/run/current-system/sw/bin/nix-copy-closure";
options = ["NOPASSWD"];
}
];
}
];
} }
+6 -4
View File
@@ -1,7 +1,9 @@
args: args:
# execute and import all overlay files in the current directory with the given args # execute and import all overlay files in the current directory with the given args
builtins.map builtins.map
(f: (import (./. + "/${f}") args)) # execute and import the overlay file (f: (import (./. + "/${f}") args)) # execute and import the overlay file
(builtins.filter # find all overlay files in the current directory
(f: f != "default.nix") (builtins.filter # find all overlay files in the current directory
(builtins.attrNames (builtins.readDir ./.)))
(f: f != "default.nix")
(builtins.attrNames (builtins.readDir ./.)))
+2 -4
View File
@@ -1,12 +1,10 @@
# 为了不使用默认的 rime-data,改用我自定义的小鹤音形数据,这里需要 override # 为了不使用默认的 rime-data,改用我自定义的小鹤音形数据,这里需要 override
# 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix # 参考 https://github.com/NixOS/nixpkgs/blob/e4246ae1e7f78b7087dce9c9da10d28d3725025f/pkgs/tools/inputmethods/fcitx5/fcitx5-rime.nix
{ ... }: {...}: (self: super: {
(self: super: {
# 小鹤音形配置,配置来自 flypy.com 官方网盘的鼠须管配置压缩包「小鹤音形“鼠须管”for macOS.zip」 # 小鹤音形配置,配置来自 flypy.com 官方网盘的鼠须管配置压缩包「小鹤音形“鼠须管”for macOS.zip」
# 我仅修改了 default.yaml 文件,将其中的半角括号改为了直角括号「 与 」。 # 我仅修改了 default.yaml 文件,将其中的半角括号改为了直角括号「 与 」。
rime-data = ./rime-data-flypy; rime-data = ./rime-data-flypy;
fcitx5-rime = super.fcitx5-rime.override { rimeDataPkgs = [ ./rime-data-flypy ]; }; fcitx5-rime = super.fcitx5-rime.override {rimeDataPkgs = [./rime-data-flypy];};
# used by macOS Squirrel # used by macOS Squirrel
flypy-squirrel = ./rime-data-flypy; flypy-squirrel = ./rime-data-flypy;
+9 -5
View File
@@ -1,7 +1,12 @@
{ config, pkgs, agenix, mysecrets, ... }:
{ {
config,
pkgs,
agenix,
mysecrets,
username,
...
}: {
imports = [ imports = [
agenix.darwinModules.default agenix.darwinModules.default
]; ];
@@ -12,7 +17,7 @@
# if you changed this key, you need to regenerate all encrypt files from the decrypt contents! # if you changed this key, you need to regenerate all encrypt files from the decrypt contents!
age.identityPaths = [ age.identityPaths = [
"/Users/ryan/.ssh/juliet-age" # macOS "/Users/${username}/.ssh/juliet-age" # macOS
]; ];
age.secrets = { age.secrets = {
@@ -56,5 +61,4 @@
system.activationScripts.postUserActivation.text = '' system.activationScripts.postUserActivation.text = ''
sudo chmod 644 /etc/agenix/* sudo chmod 644 /etc/agenix/*
''; '';
} }
+9 -4
View File
@@ -1,7 +1,12 @@
{ config, pkgs, agenix, mysecrets, ... }:
{ {
config,
pkgs,
agenix,
mysecrets,
username,
...
}: {
imports = [ imports = [
agenix.nixosModules.default agenix.nixosModules.default
]; ];
@@ -12,7 +17,7 @@
# if you changed this key, you need to regenerate all encrypt files from the decrypt contents! # if you changed this key, you need to regenerate all encrypt files from the decrypt contents!
age.identityPaths = [ age.identityPaths = [
"/home/ryan/.ssh/juliet-age" # Linux "/home/${username}/.ssh/juliet-age" # Linux
]; ];
# Used only by NixOS Modules # Used only by NixOS Modules