Nix is a Tool for building Linux systems in a declarative idempotent method and is a good fit for the CCE, I think when moving past Fedora Linux.
Using Nix in My Emacs
(provide 'cce/nixos)
(use-package nix-mode)
(use-package nixpkgs-fmt)
(use-package nix-buffer)
(use-package nix-update)
(use-package company-nixos-options
:hook
(nix-mode . (lambda ()
(make-local-variable 'company-backends)
(add-to-list 'company-backends 'company-nixos-options))))
(use-package nix-sandbox)
(defun cce-find-nix-output-at-point ()
(interactive)
(->>
(nix-store-path-at-point)
(make-instance 'nix-store-path :path )
(nix-store-fill-data )
(nix-store-path-outputs )
(completing-read "Select an output" )
(find-file)))nix and nixpkgs configuration for My NixOS configuration
{ pkgs, config, ... }:
{
# less nix crap
nix.gc = {
automatic = true;
dates = "03:30";
options = "--delete-older-than 30d";
persistent = true;
};
nix.distributedBuilds = true;
nix.buildMachines = builtins.filter (e: e.hostName != config.networking.hostName) [
# { hostName = "virtuous-cassette";
# maxJobs = 6;
# sshUser = "builder";
# systems = [
# "x86_64-linux"
# "aarch64-linux"
# ];
# }
# { hostName = "window-smoke";
# maxJobs = 6;
# sshUser = "builder";
# systems = [
# "x86_64-linux"
# "i686-linux"
# "aarch64-linux"
# ];
# }
{ hostName = "last-bank";
maxJobs = 32;
sshUser = "builder";
systems = [
"x86_64-linux"
"i686-linux"
"aarch64-linux"
];
}
] ;
nix.settings.trusted-users = ["rrix" "root" "@wheel"];
nix.settings.extra-experimental-features = [ "flakes" "nix-command" ];
# hahaha! yes
# nixpkgs.config = { allowUnfree = true; };
environment.systemPackages = with pkgs; [
nix-tree
nix-du
nurl
];
imports = [ ./ccache.nix ];
}{ config, pkgs, ... }:
{
programs.ccache.enable = true;
nix.settings.extra-sandbox-paths = [ config.programs.ccache.cacheDir ];
systemd.tmpfiles.rules = [
"d ${config.programs.ccache.cacheDir} 1770 root nixbld -"
];
nixpkgs.overlays = [
(self: super: {
ccacheWrapper = super.ccacheWrapper.override {
extraConfig = ''
export CCACHE_COMPRESS=1
export CCACHE_DIR="${config.programs.ccache.cacheDir}"
export CCACHE_UMASK=007
if [ ! -d "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' does not exist"
echo "Please create it with:"
echo " sudo mkdir -m0770 '$CCACHE_DIR'"
echo " sudo chown root:nixbld '$CCACHE_DIR'"
echo "====="
exit 1
fi
if [ ! -w "$CCACHE_DIR" ]; then
echo "====="
echo "Directory '$CCACHE_DIR' is not accessible for user $(whoami)"
echo "Please verify its access permissions"
echo "====="
exit 1
fi
'';
};
})
];
}DONE remove the nixpkgs.config.permittedInsecurePackages from nix.conf..
Installing Nix on non-NixOS machines
- name: /nix exists
file:
path: /nix
state: directory
owner: "{{local_account}}"
group: "{{local_account}}"
tags:
- nixos
- name: nix installed
shell:
executable: /bin/bash
cmd: "bash <(curl -L https://nixos.org/nix/install) --no-daemon"
creates: /nix/store/
become: yes
become_user: "{{local_account}}"
tags:
- nixosThe Ansible Manages my Laptop until I deploy NixOS and adapt CCE for it.
if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi