Skip to content

Commit

Permalink
Add Nix configuration files for common packages and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
yousiki committed Dec 1, 2024
1 parent ed3ac8f commit 9d27d75
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 100 deletions.
55 changes: 55 additions & 0 deletions modules/common/nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
lib,
pkgs,
inputs,
system,
...
}: {
# Nix configurations.
nix = {
settings = let
flake = import "${inputs.self}/flake.nix";
in {
# Nix will instruct remote build machines to use their own binary substitutes if available.
builders-use-substitutes = true;
# Experimental nix features.
experimental-features = ["flakes" "nix-command"];
# Nix will fall back to building from source if a binary substitute fails.
fallback = true;
# The garbage collector will keep the derivations from which non-garbage store paths were built.
keep-derivations = true;
# The garbage collector will keep the outputs of non-garbage derivations.
keep-outputs = true;
# Builds will be performed in a sandboxed environment on Linux.
sandbox = pkgs.stdenv.isLinux;
# These users will have additional rights when connecting to the Nix daemon.
trusted-users = ["root" "@wheel" "@admin"];
# Never warn about dirty Git/Mercurial trees.
warn-dirty = false;
# Substituters and public keys.
inherit (flake.nixConfig) substituters trusted-substituters trusted-public-keys;
};
# Nix automatically detects files in the store that have identical contents, and replaces them with hard links to a single copy.
optimise.automatic = true;
# Garbage collector
gc.automatic = true;
# List of directories to be searched for <...> file references.
nixPath =
[
"nixpkgs=flake:nixpkgs"
"home-manager=flake:home-manager"
]
++ (
lib.optional
pkgs.stdenv.isDarwin
"darwin=/etc/nix/inputs/darwin"
);
registry =
lib.mapAttrs
(_n: v: {flake = v;})
(lib.filterAttrs (n: _v: !(lib.hasPrefix "nixpkgs" n) && n != "self") inputs);
};

# The platform the configuration will be used on.
nixpkgs.hostPlatform = system;
}
29 changes: 29 additions & 0 deletions modules/common/packages/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
pkgs,
...
}: {
environment.systemPackages = with pkgs; [
coreutils-full
curl
eza
fd
fzf
git
helix
home-manager
htop
jq
man
rclone
ripgrep
rsync
tmux
unzip
wget
zellij
zoxide
zstd
];

programs.zsh.enable = true;
}
57 changes: 6 additions & 51 deletions modules/darwin/basic/default.nix
Original file line number Diff line number Diff line change
@@ -1,71 +1,26 @@
{
lib,
pkgs,
inputs,
system,
...
}: {
# Nix configurations.
nix = {
settings = let
flake = import "${inputs.self}/flake.nix";
in {
# Nix will instruct remote build machines to use their own binary substitutes if available.
builders-use-substitutes = true;
# Experimental nix features.
experimental-features = ["flakes" "nix-command"];
# Nix will fall back to building from source if a binary substitute fails.
fallback = true;
# The garbage collector will keep the derivations from which non-garbage store paths were built.
keep-derivations = true;
# The garbage collector will keep the outputs of non-garbage derivations.
keep-outputs = true;
# Builds will be performed in a sandboxed environment on Linux.
sandbox = pkgs.stdenv.isLinux;
# These users will have additional rights when connecting to the Nix daemon.
trusted-users = ["root" "@wheel" "@admin"];
# Never warn about dirty Git/Mercurial trees.
warn-dirty = false;
# Substituters and public keys.
inherit (flake.nixConfig) substituters trusted-substituters trusted-public-keys;
};
# Nix automatically detects files in the store that have identical contents, and replaces them with hard links to a single copy.
optimise.automatic = true;
# Garbage collector
gc.automatic = true;
# List of directories to be searched for <...> file references.
nixPath =
[
"nixpkgs=flake:nixpkgs"
"home-manager=flake:home-manager"
]
++ (
lib.optional
pkgs.stdenv.isDarwin
"darwin=/etc/nix/inputs/darwin"
);
registry =
lib.mapAttrs
(_n: v: {flake = v;})
(lib.filterAttrs (n: _v: !(lib.hasPrefix "nixpkgs" n) && n != "self") inputs);
};
imports = [
(lib.snowfall.fs.get-file
"modules/common/nix/default.nix")
(lib.snowfall.fs.get-file
"modules/common/packages/default.nix")
];

# Set Git commit hash for darwin-version.
system.configurationRevision = inputs.self.rev or inputs.self.dirtyRev or null;

# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;

# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh.enable = true; # default shell

# Home-manager automatically backup extension.
home-manager.backupFileExtension = "bak";

# Used for backwards compatibility, please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 5;

# The platform the configuration will be used on.
nixpkgs.hostPlatform = system;
}
24 changes: 24 additions & 0 deletions modules/home/programs/terminal/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
lib,
namespace,
config,
...
}: let
cfg = config.${namespace}.programs.terminal.neovim;
in {
options.${namespace}.programs.terminal.neovim = {
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable neovim.";
};
};

config = lib.mkIf cfg.enable {
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
};
};
}
1 change: 1 addition & 0 deletions modules/home/suites/terminal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ in {
gdu.enable = true;
git.enable = true;
mcfly.enable = true;
neovim.enable = true;
starship.enable = true;
tmux.enable = true;
yazi.enable = true;
Expand Down
55 changes: 6 additions & 49 deletions modules/nixos/basic/default.nix
Original file line number Diff line number Diff line change
@@ -1,57 +1,17 @@
{
lib,
pkgs,
inputs,
system,
...
}: {
# Nix configurations.
nix = {
settings = let
flake = import "${inputs.self}/flake.nix";
in {
# Nix will instruct remote build machines to use their own binary substitutes if available.
builders-use-substitutes = true;
# Experimental nix features.
experimental-features = ["flakes" "nix-command"];
# Nix will fall back to building from source if a binary substitute fails.
fallback = true;
# The garbage collector will keep the derivations from which non-garbage store paths were built.
keep-derivations = true;
# The garbage collector will keep the outputs of non-garbage derivations.
keep-outputs = true;
# Builds will be performed in a sandboxed environment on Linux.
sandbox = pkgs.stdenv.isLinux;
# These users will have additional rights when connecting to the Nix daemon.
trusted-users = ["root" "@wheel" "@admin"];
# Never warn about dirty Git/Mercurial trees.
warn-dirty = false;
# Substituters and public keys.
inherit (flake.nixConfig) substituters trusted-substituters trusted-public-keys;
};
# Nix automatically detects files in the store that have identical contents, and replaces them with hard links to a single copy.
optimise.automatic = true;
# Garbage collector
gc.automatic = true;
# List of directories to be searched for <...> file references.
nixPath =
[
"nixpkgs=flake:nixpkgs"
"home-manager=flake:home-manager"
]
++ (
lib.optional
pkgs.stdenv.isDarwin
"darwin=/etc/nix/inputs/darwin"
);
registry =
lib.mapAttrs
(_n: v: {flake = v;})
(lib.filterAttrs (n: _v: !(lib.hasPrefix "nixpkgs" n) && n != "self") inputs);
};
imports = [
(lib.snowfall.fs.get-file
"modules/common/nix/default.nix")
(lib.snowfall.fs.get-file
"modules/common/packages/default.nix")
];

# Default user shell: zsh
programs.zsh.enable = true;
users.defaultUserShell = pkgs.zsh;

# Home-manager automatically backup extension.
Expand All @@ -60,9 +20,6 @@
# Used for backwards compatibility, please read the changelog before changing.
system.stateVersion = "24.11";

# The platform the configuration will be used on.
nixpkgs.hostPlatform = system;

# Use sudo without password.
security.sudo.wheelNeedsPassword = false;

Expand Down

0 comments on commit 9d27d75

Please sign in to comment.