176 lines
6.8 KiB
Nix
176 lines
6.8 KiB
Nix
{
|
|
description = "Home Manager configuration";
|
|
inputs = {
|
|
devshell.url = "github:numtide/devshell";
|
|
flake-parts = {
|
|
url = "github:hercules-ci/flake-parts";
|
|
inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
};
|
|
home-manager = {
|
|
url = "github:nix-community/home-manager";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
lix-module = {
|
|
url = "https://git.lix.systems/lix-project/nixos-module/archive/main.tar.gz";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
nixgl = {
|
|
url = "github:nix-community/nixGL";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
nur.url = "github:nix-community/NUR";
|
|
git-hooks-nix.url = "github:cachix/git-hooks.nix";
|
|
sops-nix = {
|
|
url = "github:Mic92/sops-nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
};
|
|
outputs =
|
|
inputs@{ flake-parts, ... }:
|
|
flake-parts.lib.mkFlake { inherit inputs; } (
|
|
{ withSystem, ... }:
|
|
{
|
|
systems = [ "aarch64-linux" ];
|
|
imports = [
|
|
inputs.devshell.flakeModule
|
|
inputs.git-hooks-nix.flakeModule
|
|
inputs.home-manager.flakeModules.home-manager
|
|
inputs.treefmt-nix.flakeModule
|
|
# ./home/flake-module.nix
|
|
];
|
|
flake = {
|
|
homeConfigurations = {
|
|
asahi = withSystem "aarch64-linux" (
|
|
{ pkgs, ... }:
|
|
inputs.home-manager.lib.homeManagerConfiguration {
|
|
inherit pkgs;
|
|
extraSpecialArgs = { inherit inputs pkgs; };
|
|
modules = [
|
|
./home/home.nix
|
|
inputs.lix-module.nixosModules.default
|
|
inputs.sops-nix.homeManagerModules.sops
|
|
{ nixpkgs.overlays = [ inputs.nur.overlays.default ]; }
|
|
];
|
|
}
|
|
);
|
|
};
|
|
};
|
|
perSystem =
|
|
{ system, config, ... }:
|
|
let
|
|
pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
inputs.nur.overlays.default
|
|
inputs.nixgl.overlays.default
|
|
];
|
|
};
|
|
treefmt = config.treefmt.build.wrapper;
|
|
langDir = ./languages;
|
|
langFiles = builtins.attrNames (builtins.readDir langDir);
|
|
nixFiles = builtins.filter (name: builtins.match ".*\\.nix" name != null) langFiles;
|
|
configs = map (file: import (langDir + "/${file}") { inherit pkgs treefmt; }) nixFiles;
|
|
helixLanguages = {
|
|
language = map (cfg: cfg.helix.language) (
|
|
(builtins.filter (cfg: builtins.hasAttr "language" cfg.helix) (
|
|
builtins.filter (cfg: builtins.hasAttr "helix" cfg) configs
|
|
))
|
|
);
|
|
language-server = builtins.foldl' (acc: cfg: acc // (cfg.helix.language-server or { })) { } configs;
|
|
};
|
|
treefmtPrograms = builtins.foldl' (acc: cfg: acc // (cfg.treefmt.programs or { })) { } configs;
|
|
preCommitHooks = builtins.foldl' (acc: cfg: acc // (cfg.pre-commit or { })) { } configs;
|
|
devshellCommands = builtins.concatMap (cfg: cfg.devshell.commands) (
|
|
(builtins.filter (cfg: builtins.hasAttr "commands" cfg.devshell) (
|
|
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
|
))
|
|
);
|
|
devshellPackages = builtins.concatMap (cfg: cfg.devshell.packages) (
|
|
(builtins.filter (cfg: builtins.hasAttr "packages" cfg.devshell) (
|
|
builtins.filter (cfg: builtins.hasAttr "devshell" cfg) configs
|
|
))
|
|
);
|
|
helixLanguagesFormat = pkgs.formats.toml { };
|
|
helixLanguagesFile = helixLanguagesFormat.generate "languages.toml" helixLanguages;
|
|
in
|
|
{
|
|
_module.args.pkgs = pkgs;
|
|
devshells.default = {
|
|
commands = [
|
|
{
|
|
help = "`home-manager switch` for asahi";
|
|
name = "switch-asahi";
|
|
command = "${pkgs.home-manager}/bin/home-manager switch --flake .#asahi";
|
|
}
|
|
{
|
|
help = "`home-manager switch` for asahi with backup";
|
|
name = "switch-asahi-backup";
|
|
command = "${pkgs.home-manager}/bin/home-manager switch --flake .#asahi -b backup";
|
|
}
|
|
{
|
|
help = "update dependencies";
|
|
name = "update";
|
|
command = "${pkgs.lix}/bin/nix flake update";
|
|
}
|
|
{
|
|
help = "show home-manager documentation";
|
|
name = "man-home";
|
|
command = "${pkgs.man}/bin/man home-configuration.nix";
|
|
}
|
|
{
|
|
help = "generate Helix grammars";
|
|
name = "_helix-grammars";
|
|
command = "${pkgs.helix}/bin/hx --grammar fetch && hx --grammar build";
|
|
}
|
|
{
|
|
help = "generate age key";
|
|
name = "_age-generate-key";
|
|
command = "${pkgs.uutils-coreutils-noprefix}/bin/mkdir -p ~/.config/sops/age && ${pkgs.age}/bin/age-keygen -o ~/.config/sops/age/keys.txt && ${pkgs.uutils-coreutils-noprefix}/bin/cat ~/.config/sops/age/keys.txt";
|
|
}
|
|
{
|
|
help = "edit secrets.yaml";
|
|
name = "sops-edit";
|
|
command = "${pkgs.sops}/bin/sops edit ./home/secrets/secrets.yaml";
|
|
}
|
|
] ++ devshellCommands;
|
|
packages = [
|
|
pkgs.age
|
|
pkgs.forgejo-cli
|
|
pkgs.git
|
|
pkgs.helix
|
|
pkgs.home-manager
|
|
pkgs.jujutsu
|
|
pkgs.lix
|
|
pkgs.man
|
|
pkgs.sops
|
|
pkgs.uutils-coreutils-noprefix
|
|
] ++ devshellPackages;
|
|
devshell = {
|
|
motd = ''
|
|
{202}🔨 Nix Laptop Configuration{reset}
|
|
$(type -p menu &>/dev/null && menu)
|
|
'';
|
|
name = "Laptop Configuration";
|
|
startup = {
|
|
helix_config = {
|
|
text = ''
|
|
mkdir -p .helix
|
|
${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${helixLanguagesFile} ./.helix/languages.toml
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
};
|
|
pre-commit.settings = {
|
|
hooks = preCommitHooks;
|
|
};
|
|
treefmt = {
|
|
projectRootFile = "flake.nix";
|
|
programs = treefmtPrograms;
|
|
};
|
|
};
|
|
}
|
|
);
|
|
}
|