Files
dotfiles/flake.nix
T

71 lines
2.3 KiB
Nix

{
description = "Ziad's portable dev environment (SteamOS, Fedora KDE, Arch, CachyOS)";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
plasma-manager = {
url = "github:nix-community/plasma-manager";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
};
konsole-daynight = {
url = "github:RustyRaptor/konsole_daynight";
flake = false;
};
};
outputs =
{
nixpkgs,
home-manager,
plasma-manager,
...
}@inputs:
let
# Username, home and repo location are read from the environment, so every
# switch runs with --impure (bin/dot does this). That keeps one flake usable
# as `deck` on SteamOS, `abc` in a webtop and `ziadarafat` on servers.
env = name: fallback: let v = builtins.getEnv name; in if v == "" then fallback else v;
username = env "USER" "deck";
homeDirectory = env "HOME" "/home/${username}";
dotfilesDir = env "DOTFILES_DIR" "${homeDirectory}/.dotfiles";
osRelease =
let
f = /etc/os-release;
lines = if builtins.pathExists f then nixpkgs.lib.splitString "\n" (builtins.readFile f) else [ ];
idLine = nixpkgs.lib.findFirst (l: nixpkgs.lib.hasPrefix "ID=" l) "ID=unknown" lines;
in
nixpkgs.lib.removePrefix "ID=" (builtins.replaceStrings [ "\"" ] [ "" ] idLine);
mkHome =
{ system, gui }:
home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
extraSpecialArgs = { inherit inputs osRelease; };
modules = [
plasma-manager.homeModules.plasma-manager
./home
{
home = { inherit username homeDirectory; };
dotfiles = { inherit gui; dir = dotfilesDir; };
}
];
};
in
{
homeConfigurations = {
full = mkHome { system = "x86_64-linux"; gui = true; };
headless = mkHome { system = "x86_64-linux"; gui = false; };
headless-aarch64 = mkHome { system = "aarch64-linux"; gui = false; };
};
};
}