Skip to content

Commit

Permalink
refactor: removed legacy code, formatted code and improved own libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Wittano committed Jan 13, 2024
1 parent 38a656a commit b82a6ce
Show file tree
Hide file tree
Showing 65 changed files with 797 additions and 996 deletions.
26 changes: 8 additions & 18 deletions configuration.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
{ config
, pkgs
, unstable
, lib
, home-manager
, username
, isDevMode ? false
, ownPackages
, ...
{ config, pkgs, unstable, lib, home-manager, isDevMode ? false, ownPackages, ...
}: {

# Nix configuration
Expand Down Expand Up @@ -87,14 +79,12 @@
# Global packages
environment = {
systemPackages = with pkgs; [ vim htop direnv bash polkit_gnome ];
variables =
let projectConfigDir = "/home/wittano/projects/config";
in
{
EDITOR = "vim";
DOTFILES = "${projectConfigDir}/dotfiles";
NIX_DOTFILES = "${projectConfigDir}/nix-dotfiles";
};
variables = let projectConfigDir = "/home/wittano/projects/config";
in {
EDITOR = "vim";
DOTFILES = "${projectConfigDir}/dotfiles";
NIX_DOTFILES = "${projectConfigDir}/nix-dotfiles";
};

shells = with pkgs; [ bash ];
};
Expand Down Expand Up @@ -123,7 +113,7 @@
hardware.trackpoint.emulateWheel = true;

#User settings
users.users."${username}" = {
users.users.wittano = {
isNormalUser = true;
extraGroups = [ "wheel" ];
};
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 15 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,27 @@
};
};

outputs =
{ self
, nixpkgs
, home-manager
, ...
}@inputs:
outputs = { self, nixpkgs, home-manager, ... }@inputs:
let
system = "x86_64-linux";

lib = nixpkgs.lib.extend (sefl: super: {
hm = home-manager.lib.hm;
my = import ./lib {
inherit lib system inputs;
};
my = import ./lib { inherit lib system inputs; };
});
in
{
nixosConfigurations =
let
inherit (lib.attrsets) mapAttrs' nameValuePair;
inherit (lib.my.hosts) mkHost;
in {
nixosConfigurations = let
inherit (lib.attrsets) mapAttrs' nameValuePair;
inherit (lib.my.hosts) mkHost;

hosts = builtins.readDir ./hosts;
devHosts = mapAttrs'
(n: v:
let devName = "${n}-dev";
in
nameValuePair (devName) (mkHost {
name = devName;
isDevMode = true;
}))
hosts;
normalHosts = builtins.mapAttrs (n: v: mkHost { name = n; }) hosts;
in
normalHosts // devHosts;
hosts = builtins.readDir ./hosts;
devHosts = mapAttrs' (n: v:
let devName = "${n}-dev";
in nameValuePair (devName) (mkHost {
name = devName;
isDevMode = true;
})) hosts;
normalHosts = builtins.mapAttrs (n: v: mkHost { name = n; }) hosts;
in normalHosts // devHosts;
};
}
3 changes: 1 addition & 2 deletions home/pc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ let
signal-desktop
discord
];
in
{
in {
home = {
username = "wittano";
homeDirectory = "/home/wittano";
Expand Down
60 changes: 28 additions & 32 deletions hosts/laptop/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@
{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: {
{ config, pkgs, isDevMode ? false, ... }: {

imports = [ ./hardware.nix ./networking.nix ];

home-manager.users.wittano = ./../../home/pc;

modules =
let
enableWithDevMode = {
modules = let
enableWithDevMode = {
enable = true;
enableDevMode = isDevMode;
};
in {
desktop = { qtile = enableWithDevMode; };
editors.neovim.enable = true;
dev = {
goland.enable = true;
clion.enable = true;
};
hardware = {
sound.enable = true;
grub.enable = true;
wifi.enable = true;
virtualization = {
enable = true;
enableDevMode = isDevMode;
};
in
{
desktop = {
qtile = enableWithDevMode;
};
editors.neovim.enable = true;
dev = {
goland.enable = true;
clion.enable = true;
enableDocker = true;
};
hardware = {
sound.enable = true;
grub.enable = true;
wifi.enable = true;
virtualization = {
enable = true;
enableDocker = true;
};
nvidia.enable = true;
};
services = {
backup = {
enable = true;
backupDir = "/mnt/backup/wittano.nixos";
};
syncthing.enable = true;
redshift.enable = true;
nvidia.enable = true;
};
services = {
backup = {
enable = true;
backupDir = "/mnt/backup/wittano.nixos";
};
syncthing.enable = true;
redshift.enable = true;
};
};

}
70 changes: 34 additions & 36 deletions hosts/pc/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: {
{ config, pkgs, isDevMode ? false, ... }: {

imports = [ ./hardware.nix ./networking.nix ];

Expand All @@ -24,44 +24,42 @@

programs.droidcam.enable = true;

modules =
let
enableWithDevMode = {
modules = let
enableWithDevMode = {
enable = true;
enableDevMode = isDevMode;
};
in {
desktop = {
qtile = enableWithDevMode;
gaming = {
enable = true;
enableDevMode = isDevMode;
};
in
{
desktop = {
qtile = enableWithDevMode;
gaming = {
enable = true;
enableAdditionalDisk = true;
enableMihoyoGames = true;
};
};
dev.jvm.enable = true;
editors.neovim.enable = true;
hardware = {
sound.enable = true;
grub.enable = true;
wacom.enable = true;
virtualization.enable = true;
nvidia.enable = true;
bluetooth.enable = true;
enableAdditionalDisk = true;
enableMihoyoGames = true;
};
services = {
boinc.enable = true;
backup = {
enable = true;
backupDir = "/mnt/backup/wittano.nixos";
};
ssh.enable = true;
syncthing.enable = true;
redshift.enable = true;
prometheus.enable = true;
filebot.enable = true;
};
dev.jvm.enable = true;
editors.neovim.enable = true;
hardware = {
sound.enable = true;
grub.enable = true;
wacom.enable = true;
virtualization.enable = true;
nvidia.enable = true;
bluetooth.enable = true;
};
services = {
boinc.enable = true;
backup = {
enable = true;
backupDir = "/mnt/backup/wittano.nixos";
};
ssh.enable = true;
syncthing.enable = true;
redshift.enable = true;
prometheus.enable = true;
filebot.enable = true;
};
};

}
4 changes: 1 addition & 3 deletions hosts/pc/hardware.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@
fsType = "ext4";
};
};
swapDevices = [{
device = "/dev/disk/by-label/SWAP";
}];
swapDevices = [{ device = "/dev/disk/by-label/SWAP"; }];
}
11 changes: 5 additions & 6 deletions hosts/pc/networking.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{ config, ... }: {
assertions = [
{
assertion = !config.networking.networkmanager.enable;
message = "NetworkManager cannot be enable, causes problem with spotify interent connection";
}
];
assertions = [{
assertion = !config.networking.networkmanager.enable;
message =
"NetworkManager cannot be enable, causes problem with spotify interent connection";
}];

networking = {

Expand Down
4 changes: 2 additions & 2 deletions hosts/vm/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, pkgs, isDevMode ? false, username ? "wittano", ... }: {
{ config, pkgs, isDevMode ? false, ... }: {

imports = [ ./hardware.nix ];

Expand All @@ -12,7 +12,7 @@

security.rtkit.enable = true;

users.users."${username}" = {
users.users.wittano = {
isNormalUser = true;
description = "virt";
extraGroups = [ "networkmanager" "wheel" ];
Expand Down
11 changes: 5 additions & 6 deletions hosts/vm/hardware.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{ config, lib, modulesPath, username ? "wittano", ... }: {
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
{ config, lib, modulesPath, ... }: {
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];

boot = {
initrd.availableKernelModules = [ "virtio_pci" "virtio_blk" ];
loader.systemd-boot.enable = true;
};

hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
hardware.cpu.intel.updateMicrocode =
lib.mkDefault config.hardware.enableRedistributableFirmware;

networking = {
networkmanager.enable = true;
Expand All @@ -27,7 +26,7 @@
# This mounting works only for KVM virtualization.
# Before start VM, you have to add a Filesystem to your virutal machine.
# I didn't test this configuration on other hypervisor like e.g. Virutalbox, so I don't know it's will be worked
"/home/${username}/projects/config/nix-dotfiles" = {
"/home/wittano/projects/config/nix-dotfiles" = {
device = "/share";
fsType = "9p";
};
Expand Down
14 changes: 12 additions & 2 deletions lib/apps.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{ lib, pkgs, dotfiles, home-manager, ownPackages, unstable, ... }: {
importApp = cfg: name:
import (./../modules/desktop/apps + "/${name}.nix") { inherit cfg pkgs lib dotfiles home-manager ownPackages unstable; };
desktopApps = config: cfg:
let
sourceDir = ./../modules/desktop/apps;
appFiles = lib.attrsets.filterAttrs
(n: v: ((lib.strings.hasSuffix ".nix" n) && v == "regular"))
(builtins.readDir sourceDir);
in lib.attrsets.mapAttrs' (n: v: {
name = builtins.replaceStrings [ ".nix" ] [ "" ] n;
value = import "${sourceDir}/${n}" {
inherit cfg ownPackages pkgs dotfiles home-manager unstable config lib;
};
}) appFiles;
}

Loading

0 comments on commit b82a6ce

Please sign in to comment.