抽象mkOutOfStoreSymlink,为以后更新为引用相对路径做准备
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
username = "alex";
|
username = "alex";
|
||||||
useremail = "reizero@live.com";
|
useremail = "reizero@live.com";
|
||||||
|
sourcepath = "/home/${username}/.nix";
|
||||||
libs = import ./libs;
|
libs = import ./libs;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
(profile: {
|
(profile: {
|
||||||
name = profile;
|
name = profile;
|
||||||
value = import ./profiles/${profile} {
|
value = import ./profiles/${profile} {
|
||||||
inherit self inputs outputs libs username useremail;
|
inherit self inputs outputs libs sourcepath username useremail;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
(attrNames (readDir ./profiles))
|
(attrNames (readDir ./profiles))
|
||||||
|
|||||||
@@ -5,7 +5,4 @@ in
|
|||||||
{
|
{
|
||||||
# 导出mkNixosSystem函数
|
# 导出mkNixosSystem函数
|
||||||
inherit (mkNixosSystemLib) mkNixosSystem;
|
inherit (mkNixosSystemLib) mkNixosSystem;
|
||||||
|
|
||||||
# 转换相对路径到绝对路径
|
|
||||||
absolutePath = path: "${builtins.path { name = "path"; path = path; }}";
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
libs/home-libs.nix
Normal file
18
libs/home-libs.nix
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{ lib, config, sourcepath, ... }: # 声明你可能需要的参数
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
# 使用一个独特的顶层选项名,如 myLib
|
||||||
|
home-libs = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.anything;
|
||||||
|
default = { };
|
||||||
|
description = "Home manager custom utility functions.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config.home-libs = {
|
||||||
|
# path 参数目前无法通过内置函数的方式获取
|
||||||
|
# 需要是相对于 flake 的相对路径,直接由目录开始不需要加 `./`。
|
||||||
|
mkOutOfStoreSymlink = path:
|
||||||
|
config.home-libs.mkOutOfStoreSymlink "${sourcepath}/${path}";
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{ config, libs, pkgs, ... }:
|
{ config, libs, pkgs, ... }:
|
||||||
let
|
let
|
||||||
conf = [ "hypr" "waybar" "rofi" "kitty" "mako" "wlogout" ];
|
conf = [ "hypr" "waybar" "rofi" "kitty" "mako" "wlogout" ];
|
||||||
confPath = "${config.home.homeDirectory}/.nix/modules/home/hyprland/conf";
|
confPath = "modules/home/hyprland/conf";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
@@ -52,7 +52,7 @@ in
|
|||||||
(name: {
|
(name: {
|
||||||
inherit name;
|
inherit name;
|
||||||
value = {
|
value = {
|
||||||
source = config.lib.file.mkOutOfStoreSymlink "${confPath}/${name}";
|
source = config.home-libs.mkOutOfStoreSymlink "${confPath}/${name}";
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
conf
|
conf
|
||||||
|
|||||||
@@ -24,10 +24,10 @@
|
|||||||
|
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"Code/User/keybindings.json" = {
|
"Code/User/keybindings.json" = {
|
||||||
source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.nix/modules/home/vscode/keybindings.json";
|
source = config.home-libs.mkOutOfStoreSymlink "modules/home/vscode/keybindings.json";
|
||||||
};
|
};
|
||||||
"Code/User/settings.json" = {
|
"Code/User/settings.json" = {
|
||||||
source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.nix/modules/home/vscode/settings.json";
|
source = config.home-libs.mkOutOfStoreSymlink "modules/home/vscode/settings.json";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ args@{ self, pkgs, home-manager, username, sysversion, ... }: {
|
|||||||
# home-manager.useUserPackages = true;
|
# home-manager.useUserPackages = true;
|
||||||
home-manager = {
|
home-manager = {
|
||||||
extraSpecialArgs = {
|
extraSpecialArgs = {
|
||||||
inherit (args) self inputs outputs libs hostname username useremail sysversion;
|
inherit (args) self inputs outputs libs sourcepath hostname username useremail sysversion;
|
||||||
};
|
};
|
||||||
users."${username}" = { ... }: {
|
users."${username}" = { ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./hm
|
./hm
|
||||||
|
"${self}/libs/home-libs.nix"
|
||||||
"${self}/home/desktop.nix"
|
"${self}/home/desktop.nix"
|
||||||
"${self}/modules/home/develop.nix"
|
"${self}/modules/home/develop.nix"
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{ config, ... }: {
|
{ config, flakesPath, ... }: {
|
||||||
programs.ssh = {
|
programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
home.file.".ssh/config" = {
|
home.file.".ssh/config" = {
|
||||||
source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.nix/profiles/apollo/hm/ssh/config";
|
source = config.home-libs.mkOutOfStoreSymlink "profiles/apollo/hm/ssh/config";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user