Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules/community-builder: add nixpkgs clone #1455

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion modules/darwin/community-builder/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
{ inputs, pkgs, ... }:
{
config,
inputs,
pkgs,
...
}:
{
imports = [
"${inputs.self}/modules/shared/community-builder.nix"
inputs.nix-index-database.darwinModules.nix-index
./users.nix
];

environment.etc.motd.text = config.nixCommunity.motd;

environment.systemPackages = [
pkgs.vim
];

launchd.daemons.nixpkgs-clone = {
environment = {
inherit (config.environment.variables) NIX_SSL_CERT_FILE;
};
serviceConfig = {
StartCalendarInterval = [
{
Hour = 0;
Minute = 0;
}
];
StandardErrorPath = "/var/log/nixpkgs-clone.log";
StandardOutPath = "/var/log/nixpkgs-clone.log";
};
path = [
pkgs.git
];
script = builtins.readFile "${inputs.self}/modules/shared/nixpkgs-clone.bash";
};
}
18 changes: 17 additions & 1 deletion modules/nixos/community-builder/default.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
{ inputs, pkgs, ... }:
{
config,
inputs,
pkgs,
...
}:
{
imports = [
"${inputs.self}/modules/shared/community-builder.nix"
inputs.nix-index-database.nixosModules.nix-index
./users.nix
];

users.motd = config.nixCommunity.motd;

environment.systemPackages = [
# terminfo packages
pkgs.foot.terminfo
Expand All @@ -22,4 +29,13 @@
programs.fish.enable = true;
# disable generated completion
environment.etc."fish/generated_completions".text = pkgs.lib.mkForce "";

systemd.services.nixpkgs-clone = {
serviceConfig.Type = "oneshot";
startAt = "daily";
path = [
pkgs.git
];
script = builtins.readFile "${inputs.self}/modules/shared/nixpkgs-clone.bash";
};
}
61 changes: 39 additions & 22 deletions modules/shared/community-builder.nix
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
{
# useful for people that want to test stuff
environment.systemPackages = [
pkgs.fd
pkgs.git
pkgs.nano
pkgs.nix-output-monitor
pkgs.nix-tree
pkgs.nixpkgs-review
pkgs.ripgrep
pkgs.tig
];

programs.nix-index-database.comma.enable = true;

programs.zsh = {
enable = true;
# https://grml.org/zsh/grmlzshrc.html
# https://grml.org/zsh/grml-zsh-refcard.pdf
interactiveShellInit = ''
source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
options.nixCommunity.motd = lib.mkOption {
type = lib.types.str;
description = "message of the day";
};

config = {
nixCommunity.motd = ''

Welcome to Nix Community!

For a faster Nixpkgs clone use:

git clone --reference /var/lib/nixpkgs.git https://github.com/NixOS/nixpkgs.git

'';
promptInit = ""; # otherwise it'll override the grml prompt

# useful for people that want to test stuff
environment.systemPackages = [
pkgs.fd
pkgs.git
pkgs.nano
pkgs.nix-output-monitor
pkgs.nix-tree
pkgs.nixpkgs-review
pkgs.ripgrep
pkgs.tig
];

programs.nix-index-database.comma.enable = true;

programs.zsh = {
enable = true;
# https://grml.org/zsh/grmlzshrc.html
# https://grml.org/zsh/grml-zsh-refcard.pdf
interactiveShellInit = ''
source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
'';
promptInit = ""; # otherwise it'll override the grml prompt
};
};
}
5 changes: 5 additions & 0 deletions modules/shared/nixpkgs-clone.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CLONE_DIR="/var/lib/nixpkgs.git"
if [ ! -d "$CLONE_DIR" ]; then
git clone --bare https://github.com/NixOS/nixpkgs.git "$CLONE_DIR"
fi
git -C "$CLONE_DIR" -c remote.origin.fetch="+refs/heads/*:refs/remotes/origin/*" -c fetch.prune=true fetch