build(flake): add home-manager and example config

This commit is contained in:
Mohammad Rafiq 2025-07-06 22:40:22 +08:00
parent 1fc8230bfc
commit f670889e29
No known key found for this signature in database
5 changed files with 53 additions and 2 deletions

View file

@ -7,4 +7,10 @@ The list of generated files are:
- [docs/cheatsheet.md](docs/cheatsheet.md) - [docs/cheatsheet.md](docs/cheatsheet.md)
- [README.md](README.md) - [README.md](README.md)
## Structure ## Structure
The system configurations are defined in [`flake.manifest`](nix/manifest.nix). The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
The attribute `flake.modules.nixos.common` provides options that will be applied to every system.
You can use it as seen [here](nix/modules/flake/home-manager.nix):
```nix
flake.modules.nixos.common.imports = [ inputs.home-manager.nixosModules.default ];
```

21
flake.lock generated
View file

@ -96,6 +96,26 @@
"type": "github" "type": "github"
} }
}, },
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1751810302,
"narHash": "sha256-iV3C4l4XqPFcfJIHWQTOeSTuDgFg+ESdUeiYxCSgebE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "502d9b7d30a1f5940ecdb786b4f71ebf57b1ac13",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"import-tree": { "import-tree": {
"locked": { "locked": {
"lastModified": 1751399845, "lastModified": 1751399845,
@ -154,6 +174,7 @@
"files": "files", "files": "files",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"git-hooks": "git-hooks", "git-hooks": "git-hooks",
"home-manager": "home-manager",
"import-tree": "import-tree", "import-tree": "import-tree",
"make-shell": "make-shell", "make-shell": "make-shell",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",

View file

@ -9,6 +9,11 @@
url = "github:hercules-ci/flake-parts"; url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs"; inputs.nixpkgs-lib.follows = "nixpkgs";
}; };
# home-manager manages our user packages and dotfiles
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
# import-tree imports all nix files in a given directory. # import-tree imports all nix files in a given directory.
import-tree.url = "github:vic/import-tree"; import-tree.url = "github:vic/import-tree";
# files lets us write text files and automatically add checks for them # files lets us write text files and automatically add checks for them

View file

@ -8,7 +8,13 @@
''; '';
parts."Structure" = # markdown parts."Structure" = # markdown
'' ''
The system configurations are defined in [`flake.manifest`](nix/manifest.nix). The system configurations are defined in [`flake.manifest`](nix/manifest.nix).
The attribute `flake.modules.nixos.common` provides options that will be applied to every system.
You can use it as seen [here](nix/modules/flake/home-manager.nix):
```nix
flake.modules.nixos.common.imports = [ inputs.home-manager.nixosModules.default ];
```
''; '';
}; };

View file

@ -0,0 +1,13 @@
{ inputs, ... }:
let
hm = inputs.home-manager;
globalCfg = {
imports = [ hm.nixosModules.home-manager ];
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
};
in
{
imports = [ hm.flakeModules.home-manager ];
flake.modules.nixos.common = globalCfg;
}