initial commit
This commit is contained in:
commit
964aaa2468
134
flake.nix
Normal file
134
flake.nix
Normal file
|
@ -0,0 +1,134 @@
|
|||
{
|
||||
description = "You new nix config";
|
||||
|
||||
inputs = {
|
||||
# Utilities for building flakes
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# Core nix flakes
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
hardware.url = "github:nixos/nixos-hardware";
|
||||
|
||||
# Home manager flake
|
||||
home-manager.url = "github:nix-community/home-manager";
|
||||
home-manager.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# Other community flakes
|
||||
# Add any other flakes you need
|
||||
nur.url = "github:nix-community/NUR";
|
||||
impermanence.url = "github:riscadoa/impermanence";
|
||||
nix-colors.url = "github:misterio77/nix-colors";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, hardware, home-manager, nur, impermanence, nix-colors, utils }@inputs:
|
||||
let
|
||||
# Utility for building a system configuration
|
||||
mkSystem = { hostname, system }:
|
||||
nixpkgs.lib.nixosSystem {
|
||||
inherit system;
|
||||
specialArgs = { inherit inputs; };
|
||||
modules = [
|
||||
# Host configuration
|
||||
(./hosts + "/${hostname}")
|
||||
# Your custom modules
|
||||
./modules/nixos
|
||||
# Common stuff
|
||||
{
|
||||
# Add hostname
|
||||
networking.hostName = hostname;
|
||||
# Add your overlays to system config
|
||||
nixpkgs.overlays = self.overlays;
|
||||
# Add your flake inputs to system registry
|
||||
nix.registry = nixpkgs.lib.mapAttrs'
|
||||
(n: v:
|
||||
nixpkgs.lib.nameValuePair ("${n}") ({ flake = inputs."${n}"; })
|
||||
)
|
||||
inputs;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
# Utility for building a home configuration
|
||||
mkHome = { username, hostname, system }:
|
||||
home-manager.lib.homeManagerConfiguration {
|
||||
inherit username system;
|
||||
extraSpecialArgs = { inherit hostname inputs; };
|
||||
homeDirectory = "/home/${username}";
|
||||
configuration = ./home + "/${username}";
|
||||
extraModules = [
|
||||
# Your custom modules
|
||||
./modules/home-manager
|
||||
# Common stuff
|
||||
{
|
||||
# Add your overlays to home config
|
||||
nixpkgs.overlays = self.overlays;
|
||||
# Enable home-manager and git, needed for basic usage
|
||||
programs = {
|
||||
home-manager.enable = true;
|
||||
git.enable = true;
|
||||
};
|
||||
# Update services as needed
|
||||
systemd.user.startServices = "sd-switch";
|
||||
}
|
||||
];
|
||||
};
|
||||
in {
|
||||
# Overlayed packages
|
||||
overlay = (import ./overlays);
|
||||
|
||||
# This repos plus any other overlays you use
|
||||
# If you want to use out-of-nixpkgs-tree packages, add their overlays here.
|
||||
overlays = [ self.overlay nur.overlay ];
|
||||
|
||||
# System configurations
|
||||
# Accessible via 'nixos-rebuild --flake'
|
||||
nixosConfigurations = {
|
||||
cool-computer = mkSystem {
|
||||
hostname = "cool-computer";
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
very-cool-computer = mkSystem {
|
||||
hostname = "very-cool-computer";
|
||||
system = "aarch64-linux";
|
||||
};
|
||||
};
|
||||
|
||||
# Home configurations
|
||||
# Accessible via 'home-manager --flake'
|
||||
homeConfigurations = {
|
||||
"you@cool-computer" = mkHome {
|
||||
username = "you";
|
||||
hostname = "cool-computer";
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
"you@very-cool-computer" = mkHome {
|
||||
username = "you";
|
||||
hostname = "very-cool-computer";
|
||||
system = "aarch64-linux";
|
||||
};
|
||||
};
|
||||
|
||||
# Flakes templates you can access with 'nix flake init'
|
||||
templates = import ./templates;
|
||||
|
||||
} // utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; overlays = self.overlays; };
|
||||
hm = home-manager.defaultPackage."${system}";
|
||||
in {
|
||||
# Packages you can access with 'nix build'
|
||||
packages = {
|
||||
# Re-export nixpkgs' packages under the attribute "nixpkgs"
|
||||
# That way, you can test your overlays with 'nix build .#nixpkgs.package-name'
|
||||
nixpkgs = pkgs;
|
||||
# Export your custom packages. You can build them with 'nix build .#package-name'
|
||||
} // (import ./pkgs { inherit pkgs; });
|
||||
|
||||
# Devshell you can access with 'nix develop'
|
||||
# Has nix and home-manager for bootstrapping
|
||||
# plus formatter and LSP for a nice editor experience
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = with pkgs; [ nix nixfmt rnix-lsp hm ];
|
||||
};
|
||||
});
|
||||
}
|
15
home/you/default.nix
Normal file
15
home/you/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ inputs, pkgs, hostname, ... }: {
|
||||
imports = [
|
||||
# Split up your config into more files and import them here
|
||||
];
|
||||
|
||||
# Add stuff for your user as you see fit:
|
||||
# programs.neovim.enable = true;
|
||||
|
||||
# You can do stuff conditionally based on hostname, too:
|
||||
/*
|
||||
programs.alacritty = pkgs.lib.mkIf (hostname == "foo-bar") {
|
||||
enable = true;
|
||||
};
|
||||
*/
|
||||
}
|
14
hosts/common/default.nix
Normal file
14
hosts/common/default.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
# This file should hold stuff you use across all hosts
|
||||
{ inputs, pkgs, ... }: {
|
||||
system.stateVersion = "21.11";
|
||||
# Uncomment to enable unfree packages for your systems. You can also put this
|
||||
# on the specific host
|
||||
# nixpkgs.config.allowUnfree = true;
|
||||
|
||||
# This will make all users source .nix-profile on login, activating home
|
||||
# manager automatically. Will allow you to use home-manager standalone on
|
||||
# setups with opt-in persistance.
|
||||
environment.loginShellInit = ''
|
||||
[ -d "$HOME/.nix-profile" ] || /nix/var/nix/profiles/per-user/$USER/home-manager/activate &> /dev/null
|
||||
'';
|
||||
}
|
9
hosts/cool-computer/default.nix
Normal file
9
hosts/cool-computer/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ inputs, pkgs, ... }: {
|
||||
imports = [
|
||||
../common
|
||||
# You can split your config up and import other files here
|
||||
# You should also take a look at nixos-hardware and import and needed modules, such as:
|
||||
# inputs.hardware.nixosModules.common-cpu-amd
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
}
|
2
hosts/cool-computer/hardware-configuration.nix
Normal file
2
hosts/cool-computer/hardware-configuration.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# This should be generated with nixos-generated-config
|
||||
{}
|
9
hosts/very-cool-computer/default.nix
Normal file
9
hosts/very-cool-computer/default.nix
Normal file
|
@ -0,0 +1,9 @@
|
|||
{ inputs, pkgs, ... }: {
|
||||
imports = [
|
||||
../common
|
||||
# You can split your config up and import other files here
|
||||
# You should also take a look at nixos-hardware and import and needed modules, such as:
|
||||
# inputs.hardware.nixosModules.common-cpu-amd
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
}
|
2
hosts/very-cool-computer/hardware-configuration.nix
Normal file
2
hosts/very-cool-computer/hardware-configuration.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# This should be generated with nixos-generated-config
|
||||
{}
|
6
modules/home-manager/default.nix
Normal file
6
modules/home-manager/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Add your home-manager modules to this folder, then import them here.
|
||||
{
|
||||
imports = [
|
||||
# ./example.nix
|
||||
];
|
||||
}
|
6
modules/nixos/default.nix
Normal file
6
modules/nixos/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Add your nixos modules to this folder, then import them here.
|
||||
{
|
||||
imports = [
|
||||
# ./example.nix
|
||||
];
|
||||
}
|
7
overlays/default.nix
Normal file
7
overlays/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Your overlays should go here
|
||||
final: prev: {
|
||||
# example = prev.example.overrideAttrs (oldAttrs: rec {
|
||||
# ...
|
||||
# });
|
||||
} // import ../pkgs { pkgs = final; }
|
||||
# This line adds your custom packages to the overlay.
|
3
pkgs/default.nix
Normal file
3
pkgs/default.nix
Normal file
|
@ -0,0 +1,3 @@
|
|||
{ pkgs }: {
|
||||
# example = pkgs.callPackage ./example { };
|
||||
}
|
2
pkgs/example/default.nix
Normal file
2
pkgs/example/default.nix
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Packages in this directory should be just like nixpkgs'
|
||||
{}
|
0
templates/.gitkeep
Normal file
0
templates/.gitkeep
Normal file
Loading…
Reference in a new issue