Move drivers in a more appropriate folder

This commit is contained in:
Gabriel Arazas 2020-11-02 22:44:48 +08:00
parent f4dd401d87
commit 4114c91901
10 changed files with 102 additions and 54 deletions

View File

@ -142,19 +142,6 @@ My setup feature themes as a NixOS module (in link:./modules/themes[`modules/the
This lets me easily switch my graphical setup with a simple toggle (i.e., `theme.$THEME_NAME.enable = true;`) in my machine configuration (i.e., `./hosts/$HOST/default.nix`). This lets me easily switch my graphical setup with a simple toggle (i.e., `theme.$THEME_NAME.enable = true;`) in my machine configuration (i.e., `./hosts/$HOST/default.nix`).
For safety from conflicting modules and configuration, you should have a bare installation ala-Arch Linux. For safety from conflicting modules and configuration, you should have a bare installation ala-Arch Linux.
As you can see in the `default.nix` of the `modules/theme` directory, a theme should also pass in certain data to `modules.theme` as if it's enabled.
The following is an example metadata object of a theme.
[source, nix]
----
{
name = "Fair and square";
version = "0.1.0";
path = ./.;
wallpaper = "${config.modules.theme.path}/config/wallpaper";
}
----
For best practice, the general project structure of a theme should look like the following: For best practice, the general project structure of a theme should look like the following:
[source, tree] [source, tree]
@ -189,6 +176,8 @@ The link:./packages/[`./packages/`] directory contains cluster-wide https://nixo
The overlays should be put in a separate folder in `./packages/overlays/`. The overlays should be put in a separate folder in `./packages/overlays/`.
For any other packages, it should be put on the same level as `./packages/default.nix`. For any other packages, it should be put on the same level as `./packages/default.nix`.
Even though I have https://github.com/foo-dogsquared/nur-packages[a separate repo] for my packages, the packages defined here is only applicable to the setup.
To make this section longer, here is the workflow summary in creating a package: To make this section longer, here is the workflow summary in creating a package:
- Create a test file (i.e., `./packages/$PACKAGE.nix`). - Create a test file (i.e., `./packages/$PACKAGE.nix`).
@ -212,19 +201,25 @@ It'll be a full-time geeky story if I have to explain so I'll put it in a bullet
That fact alone blew my mind ever since I saw @hlissner's NixOS and the temptation just keeps growing ever since I see more NixOS-related posts. That fact alone blew my mind ever since I saw @hlissner's NixOS and the temptation just keeps growing ever since I see more NixOS-related posts.
This is where the real power of NixOS (and also https://guix.gnu.org/[GuixSD]) really made it worth the try: declarative system and local configuration. This is where the real power of NixOS (and also https://guix.gnu.org/[GuixSD]) really made it worth the try: declarative system and local configuration.
* A https://github.com/NixOS/nixpkgs/[gigantic package set] featuring \~65000 packages (similar number to AUR) as of 2020-10-29.
While NixOS is technically a source distribution (e.g., Gentoo, KISS Linux), with the reproducibility features of Nix, its https://hydra.nixos.org/[build farm], and its https://cache.nixos.org/[very large cache], you get the binary artifacts for most of its packages for free.
footnote:[If you want NixOS to be "truly a source distro", you can disable it by setting no binary caches in `nix.binaryCaches`.]
** With https://nixos.org/nixpkgs/manual/[overlays], you can change how the package is built from its source to its build instructions.
* It is reproducible (in a way, anyway). * It is reproducible (in a way, anyway).
Compared to other distros I've used in the past before discovering NixOS (which is only Arch and Fedora), it is very easy to reproduce the config. Compared to other distros I've used in the past before discovering NixOS (which is only Arch and Fedora), it is very easy to reproduce the config.
In my first day of using NixOS, I just enabled hlissner's default config and I was able to boot in just fine. In my first day of using NixOS, I just enabled hlissner's default config and I was able to boot in just fine.
(Though, changing my config into something that I want to takes the most time.) (Though, changing my config into something that I want to takes the most time.)
* Rollbacks... * Rollbacks.
Rollbacks are good. Rollbacks are good.
In system state, life with a time machine, and fighting games. In system state, life with a time machine, and fighting games.
You can just `nixos-rebuild switch --rollback` and you'll be back into your previous config. You can just `nixos-rebuild switch --rollback` and you'll be back into your previous config.
It's like Windows Restore on steroids. It's like Windows Restore on steroids.
* The packaging process is straightforward (or so I've heard). * The packaging process is straightforward.
I've yet to create one but it'll quickly change once I found my ideal set up for starting game dev as a hobby. Furthermore, it is secure since it is sandboxed (if you enabled it with `nix.useSandbox`).
* Hipster points. * Hipster points.
https://www.archlinux.org/[Arch?] https://www.archlinux.org/[Arch?]
@ -274,8 +269,15 @@ The biggest example I can think of is the parameters of a nixpkgs module (i.e.,
For an acquintance with Nix, it may not be that much of a problem. For an acquintance with Nix, it may not be that much of a problem.
However, for a newcomer, it is pretty hard to find those information with those https://nixos.org/learn.html[three manuals]. However, for a newcomer, it is pretty hard to find those information with those https://nixos.org/learn.html[three manuals].
* It does throw a bunch of traditional concepts usually found on most Linux distros with the removal of filesystem hierarchy the biggest change of them all. * The filesystem hierarchy standard is completely thrown out of the window.
Thankfully, there's been remedy to mitigate against the sudden change by retaining `/usr/bin/env` for your scripts. This means prebuilt binaries (including https://appimage.org/[AppImages]) will not work since the libraries needed are not in the intended locations.
If you want to use them inside Nix (or NixOS), you have https://nixos.wiki/wiki/Packaging/Binaries[to package them].
Thankfully, `/usr/bin/env` is kept for your user scripts.
* While the Nix language is nice and all, the https://github.com/NixOS/nixpkgs/tree/master/lib[standard library] which is essential if you want to go far with Nix, is pretty hard to navigate for a newcomer.
* Fully going into the "Nix way" is sometimes painful with the effort required to package a certain program compared to.
On the other hand, it is "write once, build everywhere".
* The error messages are horrible (when it's horrible)! * The error messages are horrible (when it's horrible)!
There is a https://opencollective.com/nix-errors-enhancement/updates/revising-our-road-map-phase-3[recent push on improving Nix in that aspect] but it focuses on the formatting. There is a https://opencollective.com/nix-errors-enhancement/updates/revising-our-road-map-phase-3[recent push on improving Nix in that aspect] but it focuses on the formatting.

View File

@ -102,7 +102,10 @@
android.enable = true; android.enable = true;
base.enable = true; base.enable = true;
cc.enable = true; cc.enable = true;
data.enable = true; data = {
enable = true;
dhall.enable = true;
};
documentation = { documentation = {
enable = true; enable = true;
latex.enable = true; latex.enable = true;
@ -136,7 +139,10 @@
}; };
}; };
drivers = { veikk.enable = true; }; hardware = {
audio.enable = true;
veikk.enable = true;
};
editors = { editors = {
default = "nvim"; default = "nvim";
@ -171,7 +177,7 @@
endless-sky # Losing is meh! endless-sky # Losing is meh!
minetest # Losing?! What's that? minetest # Losing?! What's that?
wesnoth # Losing is frustrating! wesnoth # Losing is frustrating!
zeroad # Losing is fun and frustrating! #zeroad # Losing is fun and frustrating!
# Installing some of the dependencies required for my scripts. # Installing some of the dependencies required for my scripts.
ffcast ffcast

View File

@ -14,7 +14,7 @@ in {
./desktop ./desktop
./dev ./dev
./drivers ./hardware
./editors ./editors
./shell ./shell
./services ./services

View File

@ -19,17 +19,8 @@ in {
production.enable = mkBoolDefault false; production.enable = mkBoolDefault false;
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
# Enable JACK for the most serious audio applications.
# services.jack = {
# jackd.enable = true;
# alsa.enable = false;
# loopback = { enable = true; };
# };
hardware.pulseaudio.package =
pkgs.pulseaudio.override { jackaudioSupport = true; };
my.packages = with pkgs; my.packages = with pkgs;
[ [
cadence # A JACK interface for newbs. cadence # A JACK interface for newbs.
@ -52,19 +43,12 @@ in {
geonkick # Create them percussions. geonkick # Create them percussions.
helm # A great synthesizer plugin. helm # A great synthesizer plugin.
hydrogen # Them drum beats composition will get good. hydrogen # Them drum beats composition will get good.
lmms # A decent libre FL Studio clone.
polyphone # Edit your fonts for sound. polyphone # Edit your fonts for sound.
#zrythm # An up-and-coming DAW in Linux town. sunvox # A modular sequencer... ooh...
#zrythm # An up-and-coming DAW in Linux town.
zynaddsubfx # Ze most advanced synthesizer I've seen so far (aside from the upcoming Vital syntehsizer). zynaddsubfx # Ze most advanced synthesizer I've seen so far (aside from the upcoming Vital syntehsizer).
# As of 2020-07-03, lmms has some trouble regarding Qt or something so at least use the "unstable" channel just to be safe.
# lmms
] else ] else
[ ]); [ ]);
# Required when enabling JACK daemon.
my.user.extraGroups = [ "audio" "jackaudio" ];
# Add the sequencer and the MIDI kernel module.
boot.kernelModules = [ "snd-seq" "snd-rawmidi" ];
}; };
} }

View File

@ -23,6 +23,6 @@ in {
(if cfg.brave.enable then [ brave ] else [ ]) (if cfg.brave.enable then [ brave ] else [ ])
++ (if cfg.firefox.enable then [ firefox-bin ] else [ ]) ++ (if cfg.firefox.enable then [ firefox-bin ] else [ ])
++ (if cfg.chromium.enable then [ chromium ] else [ ]) ++ (if cfg.chromium.enable then [ chromium ] else [ ])
++ (if cfg.nyxt.enable then [ next ] else [ ]); ++ (if cfg.nyxt.enable then [ nyxt ] else [ ]);
}; };
} }

View File

@ -1,15 +1,23 @@
# A bunch of data-related tools and libraries. # A bunch of data-related tools and libraries.
{ config, options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
with lib; { with lib;
let
cfg = config.modules.dev.data;
in {
options.modules.dev.data = { options.modules.dev.data = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
}; };
dhall.enable = mkOption {
type = types.bool;
default = false;
};
}; };
config = mkIf config.modules.dev.data.enable { config = mkIf cfg.enable {
my.packages = with pkgs; [ my.packages = with pkgs; [
cfitsio # A data library for FITS images which is an image used for analyzing your fitness level. cfitsio # A data library for FITS images which is an image used for analyzing your fitness level.
hdf5 # A binary data format with hierarchy and metadata. hdf5 # A binary data format with hierarchy and metadata.
@ -18,6 +26,15 @@ with lib; {
pup # A cute little puppy that can understand HTML. pup # A cute little puppy that can understand HTML.
sqlite # A cute little battle-tested library for your data abominations. sqlite # A cute little battle-tested library for your data abominations.
sqlitebrowser # Skim the DB and create a quick scraping script for it. sqlitebrowser # Skim the DB and create a quick scraping script for it.
]; ] ++
(if cfg.dhall.enable then [
dhall # A dull programmable configuration Turing-incomplete language for your guaranteed termination, neat.
dhall-nix
dhall-bash
dhall-json
dhall-text
dhall-lsp-server
] else []);
}; };
} }

View File

@ -1,5 +0,0 @@
{ config, lib, ... }:
{
imports = [ ./veikk.nix ];
}

View File

@ -0,0 +1,36 @@
{ config, options, lib, pkgs, ... }:
with lib;
let
cfg = config.modules.hardware.audio;
in {
options.modules.hardware.audio = let
mkBoolDefault = bool:
mkOption {
type = types.bool;
default = false;
};
in {
enable = mkBoolDefault false;
jack.enable = mkBoolDefault false;
};
config = mkIf cfg.enable {
# Enable JACK for the most serious audio applications.
# services.jack = {
# jackd.enable = true;
# alsa.enable = false;
# loopback = { enable = true; };
# };
hardware.pulseaudio.package =
pkgs.pulseaudio.override { jackaudioSupport = true; };
# Required when enabling JACK daemon.
# USERADD: When the other users also want to take advantage of the audio systems.
my.user.extraGroups = [ "audio" "jackaudio" ];
# Add the sequencer and the MIDI kernel module.
boot.kernelModules = [ "snd-seq" "snd-rawmidi" ];
};
}

5
modules/hardware/default.nix Executable file
View File

@ -0,0 +1,5 @@
{ config, lib, ... }:
{
imports = [ ./veikk.nix ./audio.nix ];
}

View File

@ -1,15 +1,18 @@
# Installs the VEIKK Linux driver at https://github.com/jlam55555/veikk-linux-driver. # Installs the VEIKK Linux driver at https://github.com/jlam55555/veikk-linux-driver.
{ config, options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
with lib; { with lib;
options.modules.drivers.veikk = { let
cfg = config.modules.hardware.veikk;
in {
options.modules.hardware.veikk = {
enable = mkOption { enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
}; };
}; };
config = mkIf config.modules.drivers.veikk.enable { config = mkIf cfg.enable {
boot.extraModulePackages = [ pkgs.veikk-linux-driver ]; boot.extraModulePackages = [ pkgs.veikk-linux-driver ];
}; };
} }