Add NixOS support
This commit is contained in:
91
configuration.nix
Normal file
91
configuration.nix
Normal file
@@ -0,0 +1,91 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./hardware-configuration.nix ];
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
|
||||
# Bootloader.
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
# Enable networking
|
||||
networking.hostName = "trudepc";
|
||||
networking.networkmanager.enable = true;
|
||||
|
||||
# Select internationalisation properties.
|
||||
time.timeZone = "Europe/Lisbon";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
i18n.extraLocaleSettings = {
|
||||
LC_ADDRESS = "pt_PT.UTF-8";
|
||||
LC_IDENTIFICATION = "pt_PT.UTF-8";
|
||||
LC_MEASUREMENT = "pt_PT.UTF-8";
|
||||
LC_MONETARY = "pt_PT.UTF-8";
|
||||
LC_NAME = "pt_PT.UTF-8";
|
||||
LC_NUMERIC = "pt_PT.UTF-8";
|
||||
LC_PAPER = "pt_PT.UTF-8";
|
||||
LC_TELEPHONE = "pt_PT.UTF-8";
|
||||
LC_TIME = "pt_PT.UTF-8";
|
||||
};
|
||||
|
||||
# Enable the GNOME windowing system.
|
||||
services.xserver.enable = true;
|
||||
services.xserver.displayManager.gdm.enable = true;
|
||||
services.xserver.desktopManager.gnome.enable = true;
|
||||
services.printing.enable = true; # CUPS
|
||||
services.pulseaudio.enable = false;
|
||||
security.rtkit.enable = true;
|
||||
services.pipewire = {
|
||||
enable = true;
|
||||
alsa.enable = true;
|
||||
alsa.support32Bit = true;
|
||||
pulse.enable = true;
|
||||
# If you want to use JACK applications, uncomment this
|
||||
#jack.enable = true;
|
||||
};
|
||||
# Enable touchpad support (enabled default in most desktopManager).
|
||||
# services.xserver.libinput.enable = true;
|
||||
|
||||
# Configure keymap in X11
|
||||
services.xserver.xkb = {
|
||||
layout = "us";
|
||||
variant = "altgr-intl";
|
||||
};
|
||||
|
||||
# Define a user account. Don't forget to set a password with ‘passwd’.
|
||||
users.users.trude = {
|
||||
isNormalUser = true;
|
||||
description = "TrudeEH";
|
||||
extraGroups = [ "networkmanager" "wheel" ];
|
||||
packages = with pkgs; [ # GUI and user apps
|
||||
vscode brave discord prismlauncher
|
||||
];
|
||||
};
|
||||
|
||||
# System packages
|
||||
environment.systemPackages = with pkgs; [
|
||||
git curl wget pass lynis bat
|
||||
neovim tmux htop fzf
|
||||
];
|
||||
|
||||
programs.gnupg.agent.enable = true;
|
||||
|
||||
programs.steam = {
|
||||
enable = true;
|
||||
remotePlay.openFirewall = true;
|
||||
dedicatedServer.openFirewall = true;
|
||||
};
|
||||
|
||||
# Firewall
|
||||
networking.firewall.allowedTCPPorts = [ 22 ];
|
||||
# networking.firewall.allowedUDPPorts = [ ... ];
|
||||
|
||||
# Allow running executables.
|
||||
programs.nix-ld = {
|
||||
enable = true;
|
||||
libraries = with pkgs; [
|
||||
# Add any missing dynamic libraries for unpacked programs here.
|
||||
];
|
||||
};
|
||||
|
||||
system.stateVersion = "24.11"; # Don't change this value.
|
||||
}
|
||||
@@ -37,6 +37,7 @@ resize-with-right-button=true
|
||||
|
||||
[org/gnome/mutter]
|
||||
edge-tiling=true
|
||||
dynamic-workspaces=true
|
||||
|
||||
[org/gnome/shell]
|
||||
disabled-extensions=['tiling-assistant@ubuntu.com', 'ubuntu-dock@ubuntu.com', 'ding@rastersoft.com']
|
||||
@@ -103,3 +104,6 @@ play-sound=true
|
||||
[org/gnome/TextEditor]
|
||||
highlight-current-line=true
|
||||
show-map=true
|
||||
|
||||
[org/gnome/desktop/sound]
|
||||
event-sounds=true
|
||||
|
||||
@@ -84,13 +84,6 @@ alias cat="bat"
|
||||
|
||||
set completion-ignore-case On
|
||||
|
||||
# bash-completion
|
||||
if [[ "$OSTYPE" != "darwin"* ]] && [ ! -f /usr/share/bash-completion/bash_completion ]; then
|
||||
p i bash-completion
|
||||
fi
|
||||
|
||||
. /usr/share/bash-completion/bash_completion
|
||||
|
||||
export OFLAGS="--ozone-platform-hint=auto"
|
||||
|
||||
export PATH=$PATH:$HOME/.local/bin
|
||||
|
||||
22
install.sh
22
install.sh
@@ -37,15 +37,13 @@ install_gnome_extension() {
|
||||
fi
|
||||
}
|
||||
|
||||
mkdir -p "$HOME/dotfiles/logs"
|
||||
|
||||
# Clone Dotfiles if not already present
|
||||
cd "$HOME/dotfiles"
|
||||
if [ "$(pwd)" != "$HOME/dotfiles" ]; then
|
||||
printf "${YELLOW}Cloning dotfiles repository...${NC}\n"
|
||||
git clone https://github.com/TrudeEH/dotfiles --depth 1
|
||||
if [ $? -ne 0 ]; then
|
||||
printf "${RED}Error cloning dotfiles repository. Exiting...${NC}\n"
|
||||
printf "${RED}Error cloning dotfiles repository. Is git installed? Exiting...${NC}\n"
|
||||
exit 2
|
||||
fi
|
||||
cd dotfiles || exit
|
||||
@@ -62,6 +60,18 @@ fi
|
||||
|
||||
source ./scripts/p.sh
|
||||
|
||||
# NixOS
|
||||
if grep -qi "nixos" /etc/os-release; then
|
||||
printf "${CYAN}NixOS detected.${NC}\n"
|
||||
nixos=true
|
||||
sudo cp -f /etc/nixos/configuration.nix /etc/nixos/configuration.nix.bak
|
||||
sudo cp -f configuration.nix /etc/nixos/configuration.nix
|
||||
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
|
||||
p
|
||||
fi
|
||||
|
||||
mkdir -p "$HOME/dotfiles/logs"
|
||||
|
||||
printf "${CYAN}\n"
|
||||
printf "####################\n"
|
||||
printf "#"
|
||||
@@ -73,6 +83,7 @@ printf "${CYAN}Desktop: ${PURPLE}%s${NC}\n" "$XDG_CURRENT_DESKTOP"
|
||||
printf "\n"
|
||||
|
||||
# Install Programs
|
||||
if [ -z "$nixos" ]; then
|
||||
programs=(neovim curl git tmux htop fzf gcc make tldr pass lynis bat)
|
||||
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
@@ -80,6 +91,7 @@ if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
fi
|
||||
|
||||
p i "${programs[@]}"
|
||||
fi
|
||||
|
||||
# Copy files
|
||||
printf "${YELLOW}Installing Dotfiles...${NC}\n"
|
||||
@@ -121,7 +133,7 @@ else
|
||||
fi
|
||||
|
||||
# UFW Firewall
|
||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
if [ -z "$nixos" ] && [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
printf "${YELLOW}Setting up UFW...${NC}\n"
|
||||
sudo ufw default deny incoming
|
||||
sudo ufw default allow outgoing
|
||||
@@ -137,7 +149,7 @@ if [[ "$OSTYPE" != "darwin"* ]]; then
|
||||
else
|
||||
printf "${GREEN}UFW setup successfully.${NC}\n"
|
||||
fi
|
||||
else
|
||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
printf "${YELLOW}Enabling macOS Firewall...${NC}\n"
|
||||
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
@@ -52,10 +52,13 @@ p() (
|
||||
if [[ ${packageManagers[@]} =~ "nix" ]]; then
|
||||
printf "%b\n" "${YELLOW}Updating nix...${ENDCOLOR}"
|
||||
nix-channel --update
|
||||
nix-collect-garbage --delete-older-than 7d
|
||||
nix-collect-garbage --delete-older-than 7d &>/dev/null
|
||||
if command -v nixos-rebuild >/dev/null 2>&1; then
|
||||
sudo nix-channel --update
|
||||
sudo nixos-rebuild switch
|
||||
printf "${YELLOW}Rebuilding NixOS...${NC}\n"
|
||||
sudo nixos-rebuild switch &>/tmp/nixos_rebuild.log || (
|
||||
cat /tmp/nixos_rebuild.log | grep --color error && false
|
||||
)
|
||||
fi
|
||||
fi
|
||||
if [[ ${packageManagers[@]} =~ "brew" ]]; then
|
||||
|
||||
Reference in New Issue
Block a user