dotfiles/flake.nix

126 lines
4.0 KiB
Nix
Raw Normal View History

2022-01-18 13:40:11 +02:00
{
inputs = {
2023-06-02 23:28:04 +03:00
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
2023-01-28 23:03:00 +02:00
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
2023-06-04 14:08:22 +03:00
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.home-manager.follows = "home-manager";
inputs.darwin.follows = "";
};
2022-01-18 13:40:11 +02:00
home-manager = {
2023-06-02 23:28:04 +03:00
url = "github:rycee/home-manager/release-23.05";
2023-01-14 21:37:45 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
emacs-overlay.url = "github:nix-community/emacs-overlay";
# nix-alien = {
# url = "github:thiagokokada/nix-alien";
# inputs.nixpkgs.follows = "nixpkgs";
# };
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixos-wsl = {
url = "github:nix-community/NixOS-WSL";
2022-01-18 13:40:11 +02:00
inputs.nixpkgs.follows = "nixpkgs";
};
2023-01-14 21:37:45 +02:00
co-work.url = "git+ssh://git@github.com/tudurom/co-work.git";
2022-01-22 18:39:56 +02:00
site.url = github:tudurom/site;
blog.url = github:tudurom/blog;
2022-01-18 13:40:11 +02:00
};
2022-01-22 16:39:24 +02:00
2023-01-14 21:37:45 +02:00
outputs = { self, nixpkgs, co-work, ... } @ inputs:
let
vars = {
stateVersion = "22.05";
emacs = "emacsPgtkNativeComp";
2023-06-04 14:09:14 +03:00
username = "tudor";
2023-01-14 21:37:45 +02:00
};
mkPkgs = system: import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
inputs.emacs-overlay.overlay
(final: prev: {
tudor.site = inputs.site.packages.${system}.site;
tudor.blog = inputs.blog.packages.${system}.blog;
2023-01-14 22:19:13 +02:00
tudor.pong = inputs.co-work.packages.${system}.pong;
2023-01-28 23:03:00 +02:00
unstable = import inputs.unstable { inherit system; config.allowUnfree = true; };
home-manager = inputs.home-manager.packages.${system}.home-manager;
2022-01-18 13:40:11 +02:00
})
];
};
2023-06-02 23:28:04 +03:00
2023-01-14 21:37:45 +02:00
mkNixOSModules = name: system: [
{
nixpkgs.pkgs = mkPkgs system;
_module.args.nixpkgs = nixpkgs;
_module.args.self = self;
2023-06-02 23:49:43 +03:00
_module.args.inputs = inputs;
2023-01-14 21:37:45 +02:00
_module.args.configName = name;
2023-06-02 23:49:43 +03:00
_module.args.vars = vars;
2023-01-14 21:37:45 +02:00
}
2023-06-04 14:08:22 +03:00
inputs.agenix.nixosModules.default
{
environment.systemPackages = [ inputs.agenix.packages.${system}.default ];
# enable ssh host key generation
services.openssh.enable = true;
}
2023-01-14 21:37:45 +02:00
inputs.home-manager.nixosModules.home-manager
2023-06-02 23:49:43 +03:00
inputs.nixos-wsl.nixosModules.wsl
2023-01-14 21:37:45 +02:00
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = false;
2023-06-02 23:28:04 +03:00
extraSpecialArgs = { inherit inputs vars; configName = name; };
2023-01-14 21:37:45 +02:00
};
}
./hosts/${name}
2022-01-18 13:40:11 +02:00
];
2023-01-14 21:37:45 +02:00
mkNixOSSystem = name: system: nixpkgs.lib.nixosSystem {
inherit system;
modules = mkNixOSModules name system;
};
mkNonNixOSEnvironment = name: user: system: inputs.home-manager.lib.homeManagerConfiguration rec {
2023-01-14 21:37:45 +02:00
pkgs = mkPkgs system;
2023-06-02 23:28:04 +03:00
extraSpecialArgs = {inherit inputs vars; configName = "normal-linux"; };
2023-01-14 21:37:45 +02:00
modules = [
{
_module.args.nixpkgs = nixpkgs;
_module.args.inputs = inputs;
2023-06-02 23:49:43 +03:00
_module.args.vars = vars;
2023-01-14 21:37:45 +02:00
}
{
home = {
homeDirectory = "/home/${user}";
username = user;
sessionVariables = {
GIT_SSH = "/usr/bin/ssh";
};
packages = [
pkgs.home-manager
];
2023-01-14 21:37:45 +02:00
};
programs.bash.profileExtra = ''
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
'';
2023-01-14 21:37:45 +02:00
}
(./users + "/${name}" + /home.nix)
2022-01-18 13:40:11 +02:00
];
2023-01-14 21:37:45 +02:00
};
in
{
nixosConfigurations."ceres" = mkNixOSSystem "ceres" "x86_64-linux";
nixosConfigurations."wsl2" = mkNixOSSystem "wsl2" "x86_64-linux";
2022-01-22 18:39:56 +02:00
2023-01-14 21:37:45 +02:00
homeConfigurations."tudor" = mkNonNixOSEnvironment "tudor" "tudor" "x86_64-linux";
packages.x86_64-linux."tudor" = self.homeConfigurations."tudor".activationPackage;
2022-01-22 18:39:56 +02:00
2023-01-14 21:37:45 +02:00
defaultPackage.x86_64-linux = (mkPkgs "x86_64-linux").nix;
2022-01-18 13:40:11 +02:00
};
}