refactor flake structure
This commit is contained in:
parent
3412ecb175
commit
66a2700943
9 changed files with 207 additions and 177 deletions
2
.envrc
2
.envrc
|
|
@ -1,3 +1,3 @@
|
|||
watch_file ./flake.nix ./flake.lock
|
||||
watch_file ./flake.lock **/*.nix
|
||||
|
||||
use flake
|
||||
|
|
|
|||
|
|
@ -15,16 +15,14 @@ Hey, you. This is my nixos configurations.
|
|||
- david@Tytonidae
|
||||
|
||||
| Specialisation | DE / WM | Shell | Editor | Terminal | Launcher | Browser | DM |
|
||||
| -------------- | --------- | ----------- | ----------- | -------- | --------------- | ------- | ---------------- |
|
||||
| -------------- | ------- | ----------- | ----------- | -------- | -------- | ------- | ---------------- |
|
||||
| default | niri | fish + bash | helix + zed | ghostty | fuzzel | firefox | greetd + regreet |
|
||||
| cosmic | cosmic de | fish + bash | helix + zed | ghostty | cosmic-launcher | firefox | cosmic-greeter |
|
||||
| kde | kde | fish + bash | helix + zed | ghostty | - | firefox | sddm |
|
||||
|
||||
- david@Akun
|
||||
|
||||
| Specialisation | DE / WM | Shell | Editor | Terminal | Launcher | Browser | DM |
|
||||
| -------------- | ------- | ----------- | ----------- | -------- | -------- | ------- | ---------------- |
|
||||
| default | niri | fish + bash | helix + zed | ghostty | - | firefox | greetd + regreet |
|
||||
| default | niri | fish + bash | helix + zed | ghostty | fuzzel | firefox | greetd + regreet |
|
||||
|
||||
- alice@Cape
|
||||
|
||||
|
|
|
|||
167
flake.nix
167
flake.nix
|
|
@ -168,14 +168,21 @@
|
|||
flake-parts,
|
||||
flake-utils,
|
||||
...
|
||||
} @ inputs: let
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} ({flake-parts-lib, ...}: let
|
||||
inherit (self) outputs;
|
||||
inherit (flake-parts-lib) importApply;
|
||||
rootPath = ./.;
|
||||
in
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
nixos = importApply ./flake/nixos.nix {inherit rootPath outputs;};
|
||||
home = importApply ./flake/home.nix {inherit rootPath outputs;};
|
||||
deploy = importApply ./flake/deploy.nix {inherit outputs;};
|
||||
in {
|
||||
systems = flake-utils.lib.defaultSystems;
|
||||
imports = [
|
||||
inputs.home-manager.flakeModules.home-manager
|
||||
nixos
|
||||
home
|
||||
deploy
|
||||
];
|
||||
perSystem = {
|
||||
pkgs,
|
||||
|
|
@ -204,8 +211,11 @@
|
|||
];
|
||||
};
|
||||
};
|
||||
flake =
|
||||
{
|
||||
flake = {
|
||||
overlays = {
|
||||
modifications = import ./overlays/modifications {inherit inputs outputs;};
|
||||
additions = import ./overlays/additions {inherit inputs outputs;};
|
||||
};
|
||||
nix.settings = {
|
||||
# substituters shared in home-manager and nixos configuration
|
||||
substituters = let
|
||||
|
|
@ -217,151 +227,6 @@
|
|||
(cachix "cosmic")
|
||||
];
|
||||
};
|
||||
|
||||
nixosModules.default = import ./nixos/modules;
|
||||
|
||||
overlays = {
|
||||
modifications = import ./overlays/modifications {inherit inputs outputs;};
|
||||
additions = import ./overlays/additions {inherit inputs outputs;};
|
||||
};
|
||||
|
||||
nixosConfigurations = let
|
||||
nixosConfigDir = ./nixos/configurations;
|
||||
makeNixConfiguration = hostName:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
modules =
|
||||
[outputs.nixosModules.default]
|
||||
++ [
|
||||
(
|
||||
let
|
||||
dirPath = nixosConfigDir + "/${hostName}";
|
||||
filePath = nixosConfigDir + "/${hostName}.nix";
|
||||
in
|
||||
if builtins.pathExists dirPath
|
||||
then dirPath
|
||||
else filePath
|
||||
)
|
||||
];
|
||||
specialArgs = {inherit inputs outputs rootPath;};
|
||||
};
|
||||
in
|
||||
nixosConfigDir
|
||||
|> builtins.readDir
|
||||
|> builtins.attrNames
|
||||
|> map (f: nixpkgs.lib.removeSuffix ".nix" f)
|
||||
|> map (name: {
|
||||
inherit name;
|
||||
value = makeNixConfiguration name;
|
||||
})
|
||||
|> builtins.listToAttrs;
|
||||
}
|
||||
// (
|
||||
let
|
||||
mkHomeConfig = {
|
||||
hostName,
|
||||
unixName ? "david",
|
||||
system ? "x86_64-linux",
|
||||
nixpkgs ? inputs.nixpkgs,
|
||||
home-manager ? inputs.home-manager,
|
||||
}: {
|
||||
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
modules =
|
||||
[
|
||||
"${toString ./home}/${unixName}/configurations/${hostName}"
|
||||
]
|
||||
++ (with outputs.homeModules; [
|
||||
default
|
||||
extra
|
||||
])
|
||||
++ [
|
||||
outputs.homeModules."${unixName}"
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
inherit
|
||||
inputs
|
||||
outputs
|
||||
unixName
|
||||
hostName
|
||||
system
|
||||
rootPath
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
homeConfigurations =
|
||||
nixpkgs.lib.foldr (a: b: a // b) {} (
|
||||
map (hostName: mkHomeConfig {inherit hostName;}) [
|
||||
"Tytonidae"
|
||||
"Akun"
|
||||
]
|
||||
)
|
||||
// mkHomeConfig {
|
||||
hostName = "Cape";
|
||||
unixName = "alice";
|
||||
};
|
||||
homeModules =
|
||||
{
|
||||
default = import ./home/modules;
|
||||
extra = import ./home/extra;
|
||||
}
|
||||
// (
|
||||
./home
|
||||
|> builtins.readDir
|
||||
|> nixpkgs.lib.filterAttrs (key: value: value == "directory")
|
||||
|> nixpkgs.lib.filterAttrs (
|
||||
key: value:
|
||||
!builtins.elem key [
|
||||
"modules"
|
||||
"extra"
|
||||
]
|
||||
)
|
||||
|> builtins.attrNames
|
||||
|> map (name: {
|
||||
name = name;
|
||||
value = import "${toString ./home}/${name}/modules";
|
||||
})
|
||||
|> builtins.listToAttrs
|
||||
);
|
||||
}
|
||||
)
|
||||
// (
|
||||
let
|
||||
mkDeployNode = {
|
||||
hostName,
|
||||
unixName ? "deploy",
|
||||
system ? "x86_64-linux",
|
||||
sshName ? hostName,
|
||||
}: {
|
||||
"${hostName}" = {
|
||||
hostname = "${sshName}";
|
||||
sshUser = "${unixName}";
|
||||
interactiveSudo = true;
|
||||
profiles = {
|
||||
system = {
|
||||
user = "root";
|
||||
path =
|
||||
inputs.deploy-rs.lib."${system}".activate.nixos
|
||||
self.outputs.nixosConfigurations."${hostName}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
deploy.nodes =
|
||||
[
|
||||
"Cape"
|
||||
"Akun"
|
||||
]
|
||||
|> map (
|
||||
hostName:
|
||||
mkDeployNode {
|
||||
inherit hostName;
|
||||
}
|
||||
)
|
||||
|> nixpkgs.lib.foldr (a: b: a // b) {};
|
||||
}
|
||||
);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
|||
49
flake/deploy.nix
Normal file
49
flake/deploy.nix
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{outputs}: {
|
||||
lib,
|
||||
inputs,
|
||||
flake-parts-lib,
|
||||
...
|
||||
}: let
|
||||
mkDeployNode = {
|
||||
hostName,
|
||||
unixName ? "deploy",
|
||||
system ? "x86_64-linux",
|
||||
sshName ? hostName,
|
||||
}: {
|
||||
"${hostName}" = {
|
||||
hostname = "${sshName}";
|
||||
sshUser = "${unixName}";
|
||||
interactiveSudo = true;
|
||||
profiles = {
|
||||
system = {
|
||||
user = "root";
|
||||
path =
|
||||
inputs.deploy-rs.lib."${system}".activate.nixos
|
||||
outputs.nixosConfigurations."${hostName}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options = {
|
||||
flake = flake-parts-lib.mkSubmoduleOptions {
|
||||
deploy = lib.mkOption {
|
||||
type = lib.types.lazyAttrsOf lib.types.raw;
|
||||
};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
flake.deploy.nodes =
|
||||
[
|
||||
"Cape"
|
||||
"Akun"
|
||||
]
|
||||
|> map (
|
||||
hostName:
|
||||
mkDeployNode {
|
||||
inherit hostName;
|
||||
}
|
||||
)
|
||||
|> lib.foldr (a: b: a // b) {};
|
||||
};
|
||||
}
|
||||
79
flake/home.nix
Normal file
79
flake/home.nix
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
outputs,
|
||||
rootPath,
|
||||
}: {
|
||||
lib,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
homeModules =
|
||||
{
|
||||
default = import "${toString rootPath}/home/modules";
|
||||
extra = import "${toString rootPath}/home/extra";
|
||||
}
|
||||
// (
|
||||
(rootPath + "/home")
|
||||
|> builtins.readDir
|
||||
|> lib.filterAttrs (key: value: value == "directory")
|
||||
|> lib.filterAttrs (
|
||||
key: value:
|
||||
!builtins.elem key [
|
||||
"modules"
|
||||
"extra"
|
||||
]
|
||||
)
|
||||
|> builtins.attrNames
|
||||
|> map (name: {
|
||||
name = name;
|
||||
value = import "${toString rootPath}/home/${name}/modules";
|
||||
})
|
||||
|> builtins.listToAttrs
|
||||
);
|
||||
mkHomeConfig = {
|
||||
hostName,
|
||||
unixName ? "david",
|
||||
system ? "x86_64-linux",
|
||||
nixpkgs ? inputs.nixpkgs,
|
||||
home-manager ? inputs.home-manager,
|
||||
}: {
|
||||
"${unixName}@${hostName}" = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = nixpkgs.legacyPackages."${system}";
|
||||
modules =
|
||||
[
|
||||
"${toString rootPath}/home/${unixName}/configurations/${hostName}"
|
||||
]
|
||||
++ (with homeModules; [
|
||||
default
|
||||
extra
|
||||
])
|
||||
++ [
|
||||
homeModules."${unixName}"
|
||||
];
|
||||
extraSpecialArgs = {
|
||||
inherit
|
||||
inputs
|
||||
outputs
|
||||
unixName
|
||||
hostName
|
||||
system
|
||||
rootPath
|
||||
;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
flake = {
|
||||
homeConfigurations =
|
||||
lib.foldr (a: b: a // b) {} (
|
||||
map (hostName: mkHomeConfig {inherit hostName;}) [
|
||||
"Tytonidae"
|
||||
"Akun"
|
||||
]
|
||||
)
|
||||
// mkHomeConfig {
|
||||
hostName = "Cape";
|
||||
unixName = "alice";
|
||||
};
|
||||
inherit homeModules;
|
||||
};
|
||||
}
|
||||
42
flake/nixos.nix
Normal file
42
flake/nixos.nix
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
rootPath,
|
||||
outputs,
|
||||
}: {inputs, ...}: let
|
||||
defaultNixosModule = import (rootPath + "/nixos/modules");
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
in {
|
||||
flake = {
|
||||
nixosModules.default = defaultNixosModule;
|
||||
nixosConfigurations = let
|
||||
nixosConfigDir = rootPath + "/nixos/configurations";
|
||||
makeNixConfiguration = hostName:
|
||||
lib.nixosSystem {
|
||||
modules =
|
||||
[defaultNixosModule]
|
||||
++ [
|
||||
(
|
||||
let
|
||||
dirPath = nixosConfigDir + "/${hostName}";
|
||||
filePath = nixosConfigDir + "/${hostName}.nix";
|
||||
in
|
||||
if builtins.pathExists dirPath
|
||||
then dirPath
|
||||
else filePath
|
||||
)
|
||||
];
|
||||
specialArgs = {
|
||||
inherit inputs outputs rootPath;
|
||||
};
|
||||
};
|
||||
in
|
||||
nixosConfigDir
|
||||
|> builtins.readDir
|
||||
|> builtins.attrNames
|
||||
|> map (f: lib.removeSuffix ".nix" f)
|
||||
|> map (name: {
|
||||
inherit name;
|
||||
value = makeNixConfiguration name;
|
||||
})
|
||||
|> builtins.listToAttrs;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
{outputs, ...}: final: prev: let
|
||||
inherit (final) stdenv;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
inherit (prev.stdenv.hostPlatform) system;
|
||||
in {
|
||||
rime-ice = outputs.packages."${system}".rime-ice;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{outputs, ...}: final: prev: let
|
||||
inherit (final) stdenv;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
inherit (prev.stdenv.hostPlatform) system;
|
||||
in {
|
||||
juicity = outputs.packages."${system}".juicity;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
{outputs, ...}: final: prev: let
|
||||
inherit (final) stdenv;
|
||||
inherit (stdenv.hostPlatform) system;
|
||||
inherit (prev.stdenv.hostPlatform) system;
|
||||
in {
|
||||
spotify = outputs.packages."${system}".spotifyx;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue