Skip to content

Commit

Permalink
style: apply nix fmt to entire repository
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarrio committed Nov 25, 2023
1 parent 8c5234c commit 7767987
Show file tree
Hide file tree
Showing 58 changed files with 617 additions and 605 deletions.
170 changes: 85 additions & 85 deletions android/_mixins/users/nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,91 @@
let
ifExists = groups: builtins.filter (group: builtins.hasAttr group config.users.groups) groups;
install-system = pkgs.writeScriptBin "install-system" ''
#!${pkgs.stdenv.shell}
#set -euo pipefail
TARGET_HOST="''${1:-}"
TARGET_USER="''${2:-tcarrio}"
TARGET_TYPE="''${3:-}"
if [ "$(id -u)" -eq 0 ]; then
echo "ERROR! $(basename "$0") should be run as a regular user"
exit 1
fi
if [ ! -d "$HOME/0xc/nix-config/.git" ]; then
git clone https://github.com/tcarrio/nix-config.git "$HOME/0xc/nix-config"
fi
pushd "$HOME/0xc/nix-config"
if [[ -z "$TARGET_HOST" ]]; then
echo "ERROR! $(basename "$0") requires a hostname as the first argument"
echo " The following hosts are available"
ls -1 nixos/*/default.nix | cut -d'/' -f2 | grep -v iso
exit 1
fi
if [[ -z "$TARGET_USER" ]]; then
echo "ERROR! $(basename "$0") requires a username as the second argument"
echo " The following users are available"
ls -1 nixos/_mixins/users/ | grep -v -E "nixos|root"
exit 1
fi
if [[ -z "$TARGET_TYPE" ]]; then
echo "ERROR! $(basename "$0") requires a type as the third argument"
echo " The following types are available"
ls -1 nixos/ | grep -v -E "nixos|root|_mixins"
exit 1
fi
TARGET_HOST_ROOT="nixos/$TARGET_TYPE/$TARGET_HOST"
if [ ! -e "$TARGET_HOST_ROOT/disks.nix" ]; then
echo "ERROR! $(basename "$0") could not find the required $TARGET_HOST_ROOT/disks.nix"
exit 1
fi
# Check if the machine we're provisioning expects a keyfile to unlock a disk.
# If it does, generate a new key, and write to a known location.
if grep -q "data.keyfile" "$TARGET_HOST_ROOT/disks.nix"; then
echo -n "$(head -c32 /dev/random | base64)" > /tmp/data.keyfile
fi
echo "WARNING! The disks in $TARGET_HOST are about to get wiped"
echo " NixOS will be re-installed"
echo " This is a destructive operation"
echo
read -p "Are you sure? [y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo true
sudo nix run github:nix-community/disko \
--extra-experimental-features "nix-command flakes" \
--no-write-lock-file \
-- \
--mode zap_create_mount \
"$TARGET_HOST_ROOT/disks.nix"
sudo nixos-install --no-root-password --flake ".#$TARGET_HOST"
# Rsync nix-config to the target install and set the remote origin to SSH.
rsync -a --delete "$HOME/0xc/" "/mnt/home/$TARGET_USER/0xc/"
pushd "/mnt/home/$TARGET_USER/0xc/nix-config"
git remote set-url origin [email protected]:tcarrio/nix-config.git
popd
# If there is a keyfile for a data disk, put copy it to the root partition and
# ensure the permissions are set appropriately.
if [[ -f "/tmp/data.keyfile" ]]; then
sudo cp /tmp/data.keyfile /mnt/etc/data.keyfile
sudo chmod 0400 /mnt/etc/data.keyfile
fi
fi
'';
#!${pkgs.stdenv.shell}
#set -euo pipefail
TARGET_HOST="''${1:-}"
TARGET_USER="''${2:-tcarrio}"
TARGET_TYPE="''${3:-}"
if [ "$(id -u)" -eq 0 ]; then
echo "ERROR! $(basename "$0") should be run as a regular user"
exit 1
fi
if [ ! -d "$HOME/0xc/nix-config/.git" ]; then
git clone https://github.com/tcarrio/nix-config.git "$HOME/0xc/nix-config"
fi
pushd "$HOME/0xc/nix-config"
if [[ -z "$TARGET_HOST" ]]; then
echo "ERROR! $(basename "$0") requires a hostname as the first argument"
echo " The following hosts are available"
ls -1 nixos/*/default.nix | cut -d'/' -f2 | grep -v iso
exit 1
fi
if [[ -z "$TARGET_USER" ]]; then
echo "ERROR! $(basename "$0") requires a username as the second argument"
echo " The following users are available"
ls -1 nixos/_mixins/users/ | grep -v -E "nixos|root"
exit 1
fi
if [[ -z "$TARGET_TYPE" ]]; then
echo "ERROR! $(basename "$0") requires a type as the third argument"
echo " The following types are available"
ls -1 nixos/ | grep -v -E "nixos|root|_mixins"
exit 1
fi
TARGET_HOST_ROOT="nixos/$TARGET_TYPE/$TARGET_HOST"
if [ ! -e "$TARGET_HOST_ROOT/disks.nix" ]; then
echo "ERROR! $(basename "$0") could not find the required $TARGET_HOST_ROOT/disks.nix"
exit 1
fi
# Check if the machine we're provisioning expects a keyfile to unlock a disk.
# If it does, generate a new key, and write to a known location.
if grep -q "data.keyfile" "$TARGET_HOST_ROOT/disks.nix"; then
echo -n "$(head -c32 /dev/random | base64)" > /tmp/data.keyfile
fi
echo "WARNING! The disks in $TARGET_HOST are about to get wiped"
echo " NixOS will be re-installed"
echo " This is a destructive operation"
echo
read -p "Are you sure? [y/N]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo true
sudo nix run github:nix-community/disko \
--extra-experimental-features "nix-command flakes" \
--no-write-lock-file \
-- \
--mode zap_create_mount \
"$TARGET_HOST_ROOT/disks.nix"
sudo nixos-install --no-root-password --flake ".#$TARGET_HOST"
# Rsync nix-config to the target install and set the remote origin to SSH.
rsync -a --delete "$HOME/0xc/" "/mnt/home/$TARGET_USER/0xc/"
pushd "/mnt/home/$TARGET_USER/0xc/nix-config"
git remote set-url origin [email protected]:tcarrio/nix-config.git
popd
# If there is a keyfile for a data disk, put copy it to the root partition and
# ensure the permissions are set appropriately.
if [[ -f "/tmp/data.keyfile" ]]; then
sudo cp /tmp/data.keyfile /mnt/etc/data.keyfile
sudo chmod 0400 /mnt/etc/data.keyfile
fi
fi
'';
in
{
# Only include desktop components if one is supplied.
Expand Down
176 changes: 88 additions & 88 deletions android/default.nix
Original file line number Diff line number Diff line change
@@ -1,102 +1,102 @@
{ self, pkgs, hostname, username, platform, stateVersion, inputs, ... /* outputs, lib, config */ }: {
imports = [
./${hostname}
./_mixins/users/${username}
];
imports = [
./${hostname}
./_mixins/users/${username}
];

# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
# SYSTEM packages, for all users
direnv
htop
home-manager
];
# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment.systemPackages = with pkgs; [
# SYSTEM packages, for all users
direnv
htop
home-manager
];

# fonts = {
# fontDir.enable = true;
# fonts = with pkgs; [
# font-awesome
# (nerdfonts.override {
# fonts = [
# "FiraCode"
# ];
# })
# ];
# };
# fonts = {
# fontDir.enable = true;
# fonts = with pkgs; [
# font-awesome
# (nerdfonts.override {
# fonts = [
# "FiraCode"
# ];
# })
# ];
# };


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

# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";
# Necessary for using flakes on this system.
nix.settings.experimental-features = "nix-command flakes";

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

programs = {
fish = {
enable = true;
interactiveShellInit = ''
set fish_cursor_default block blink
set fish_cursor_insert line blink
set fish_cursor_replace_one underscore blink
set fish_cursor_visual block
set -U fish_color_autosuggestion brblack
set -U fish_color_cancel -r
set -U fish_color_command green
set -U fish_color_comment brblack
set -U fish_color_cwd brgreen
set -U fish_color_cwd_root brred
set -U fish_color_end brmagenta
set -U fish_color_error red
set -U fish_color_escape brcyan
set -U fish_color_history_current --bold
set -U fish_color_host normal
set -U fish_color_match --background=brblue
set -U fish_color_normal normal
set -U fish_color_operator cyan
set -U fish_color_param blue
set -U fish_color_quote yellow
set -U fish_color_redirection magenta
set -U fish_color_search_match bryellow '--background=brblack'
set -U fish_color_selection white --bold '--background=brblack'
set -U fish_color_status red
set -U fish_color_user brwhite
set -U fish_color_valid_path --underline
set -U fish_pager_color_completion normal
set -U fish_pager_color_description yellow
set -U fish_pager_color_prefix white --bold --underline
set -U fish_pager_color_progress brwhite '--background=cyan'
'';
shellAliases = {
nix-gc = "sudo nix-collect-garbage --delete-older-than 14d";
rebuild-all = "sudo nix-collect-garbage --delete-older-than 14d && darwin-rebuild switch --flake $HOME/0xc/nix-config && home-manager switch -b backup --flake $HOME/0xc/nix-config";
rebuild-home = "home-manager switch -b backup --flake $HOME/0xc/nix-config";
rebuild-host = "nix-on-droid switch --flake $HOME/0xc/nix-config";
rebuild-lock = "pushd $HOME/0xc/nix-config && nix flake lock --recreate-lock-file && popd";
# TODO: Support secrets management on macOS
# modify-secret = "agenix -i ~/.ssh/id_rsa -e"; # the path relative to /secrets must be passed
programs = {
fish = {
enable = true;
interactiveShellInit = ''
set fish_cursor_default block blink
set fish_cursor_insert line blink
set fish_cursor_replace_one underscore blink
set fish_cursor_visual block
set -U fish_color_autosuggestion brblack
set -U fish_color_cancel -r
set -U fish_color_command green
set -U fish_color_comment brblack
set -U fish_color_cwd brgreen
set -U fish_color_cwd_root brred
set -U fish_color_end brmagenta
set -U fish_color_error red
set -U fish_color_escape brcyan
set -U fish_color_history_current --bold
set -U fish_color_host normal
set -U fish_color_match --background=brblue
set -U fish_color_normal normal
set -U fish_color_operator cyan
set -U fish_color_param blue
set -U fish_color_quote yellow
set -U fish_color_redirection magenta
set -U fish_color_search_match bryellow '--background=brblack'
set -U fish_color_selection white --bold '--background=brblack'
set -U fish_color_status red
set -U fish_color_user brwhite
set -U fish_color_valid_path --underline
set -U fish_pager_color_completion normal
set -U fish_pager_color_description yellow
set -U fish_pager_color_prefix white --bold --underline
set -U fish_pager_color_progress brwhite '--background=cyan'
'';
shellAliases = {
nix-gc = "sudo nix-collect-garbage --delete-older-than 14d";
rebuild-all = "sudo nix-collect-garbage --delete-older-than 14d && darwin-rebuild switch --flake $HOME/0xc/nix-config && home-manager switch -b backup --flake $HOME/0xc/nix-config";
rebuild-home = "home-manager switch -b backup --flake $HOME/0xc/nix-config";
rebuild-host = "nix-on-droid switch --flake $HOME/0xc/nix-config";
rebuild-lock = "pushd $HOME/0xc/nix-config && nix flake lock --recreate-lock-file && popd";
# TODO: Support secrets management on macOS
# modify-secret = "agenix -i ~/.ssh/id_rsa -e"; # the path relative to /secrets must be passed

moon = "curl -s wttr.in/Moon";
nano = "vim";
pubip = "curl -s ifconfig.me/ip";
#pubip = "curl -s https://api.ipify.org";
wttr = "curl -s wttr.in && curl -s v2.wttr.in";
wttr-bas = "curl -s wttr.in/detroit && curl -s v2.wttr.in/detroit";
};
};
moon = "curl -s wttr.in/Moon";
nano = "vim";
pubip = "curl -s ifconfig.me/ip";
#pubip = "curl -s https://api.ipify.org";
wttr = "curl -s wttr.in && curl -s v2.wttr.in";
wttr-bas = "curl -s wttr.in/detroit && curl -s v2.wttr.in/detroit";
};
};
};

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

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

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

0 comments on commit 7767987

Please sign in to comment.