2020-12-21

<clever> matthewcroughan: the options and config keys are also optional
<clever> but it has its own set of modules, so things like systemd.services arent an option within HM
<clever> its using lib.evalModules, so it works the same general way as nixos
<clever> the function part is optional, if you dont need anything, you can reduce it to { options = {}; imports = []; config = {}; }
<clever> when you where doing `import ./matthew self`, you where passing the home-manager module system a naked function
<clever> the module system can take either a naked function, the path to a file containing that function, or a list of either
<clever> { config, lib, ... }: { options = {}; imports = []; config = {}; }
<clever> a module is a function that looks like this:
<clever> it should be in the nixos module docs
<clever> a module always returns a set containing 3 keys, options, imports, and config
<clever> modules are always in the form of { config, lib, ... }:
<clever> whatever is calling the function, is passing it things
<clever> matthewcroughan: the only way to get things into a nix file, is for the file to return a function, then you call that function and pass it things
<clever> matthewcroughan: basically, every nix file is evaluated in its own private scope, it never gets any context from whatever imported it
<clever> i just throw code at github and ignore the license file, lol
<clever> sphalerite: ah, that explains why i thought it was readline
<clever> sphalerite: ah, has it changed? i thought it did
<clever> jumper149: i did C-x C-r while strace'ing the repl, and it didnt read any cfg files
<clever> jumper149: it might also need the program to tell readline to read the cfg file, do the docs say anything about that?
<clever> jumper149: i believe its using libreadline, so check if that has env vars to switch its mode
<clever> there was probably a nixos.regalium and a nixoops.regalium
<clever> config.nix*
<clever> Regalium: but every channel also respects config.txt, so both channels are going to have the same override
<clever> Regalium: without -A, it will search every channel for the given pkg
<clever> nix-env -iA nixos.regalium, will use your exact override, from a channel named nixos in --list
<clever> -i will search for any package with the right .name, while -iA tells it exactly what to use
<clever> Regalium: you probably still want to use -iA
<clever> like, foo = self.foo.override....;
<clever> Regalium: does your override use the same attribute name for the replacement?
<clever> Regalium: what does `nix-channel --list` and `sudo nix-channel --list` report?
<clever> matthewcroughan: the 1st only accepts a set, which must contain the listed keys, the 2nd can accept any type
<clever> previously, it was a function that took 2 args, which can also be thought of as a function that takes 1 arg, and returns a second function
<clever> nope, in both cases you where defining a function
<clever> the module system will then supply that set to you
<clever> and that argument must be a set, containing the listed keys
<clever> matthewcroughan: your defining a function, that takes a single argument
<clever> probably
<clever> that has a collection of custom modules, that are entirely self-contained, not nixos or HM
<clever> maybe link this one?
<clever> one sec...
<clever> its internals of how lib.evalModules works
<clever> now you have 2 extra args, self and inputs
<clever> look closer, i added a 2nd line
<clever> did you add the .args.self?
<clever> and i just added self, so you can now do { config, pkgs, self, ... }:
<clever> since your not passing it a self anymore
<clever> you have to modify matthew/default.nix to remove the self: now
<clever> or a path
<clever> and a module can either be a set or a function
<clever> matthewcroughan: the matthew key, can either be a list of HM modules, or a naked HM module
<clever> like so
<clever> the way you already have it working
<clever> matthewcroughan: i think passing self thru like that is the simplest option, it already works, and gives you access to a few things
<clever> matthewcroughan: as i said: 2020-12-21 10:43:56 < clever> matthewcroughan: any time you do `{ foo, bar }:` your just creating a function that accepts "one argument", that argument MUST be a set, which contains a .foo and .bar attr
<clever> matthewcroughan: but you could also do `{ inputs, ... }: { config, lib, pkgs, ... }:`
<clever> matthewcroughan: that self.inputs will only exist, if the thing calling it, passes it a set containing inputs
<clever> that doesnt make any sense
<clever> and you would still have to set _module.args.self somewhere
<clever> and it only works one layer deep, so it would be `{ config, lib, pkgs, self, ... }:`
<clever> matthewcroughan: any time you do `{ foo, bar }:` your just creating a function that accepts "one argument", that argument MUST be a set, which contains a .foo and .bar attr
<clever> `{ config, lib, pkgs, self.inputs, ... }:` is not valid, you cant have a . in an arg name
<clever> so you get your own return value, as an argument
<clever> and then it will pass the final merged result back into every module
<clever> it will then merge the return value from every module (according to the merge rules defined in options)
<clever> it will run every module, recursively (checking each for an imports attr)
<clever> lib.evalModules is practically magic
<clever> and you must somehow set _module.args.inputs
<clever> which will pass the _module.args to every module
<clever> that function is fed to lib.evalModules
<clever> matthewcroughan: any time you import a file, that file is evaluated in an entirely clean scope, with no variables leaking over, at all
<clever> so the `users/default.nix` is effectively just doing `matthew = { config, lib, pkgs, inputs, ... }: ...`
<clever> and returns a 2nd function
<clever> this file, then puts that "self" into a new variable, also called self
<clever> the "self" that it received as an input, from flake.nix
<clever> that will import the other default.nix, and then treat it as a function, passing it 1 arg
<clever> matthew = import ./matthew self; # pass 'self' in order to allow ./users/default.nix -> ./users/matthew/default.nix to access ${self}, to provide a path relative to flake.nix.
<clever> it doesnt strip anything
<clever> matthewcroughan: its mostly due to how the nix language is pure, variables are only in scope if you received them as args to a function
<clever> config is coming from lib.evalModules
<clever> pkgs is being added by something in home-manager
<clever> and self is only in scope for that one file
<clever> because inputs is an attribute of self
<clever> matthewcroughan: so only that one module has `self` in scope
<clever> matthewcroughan: the `self:` then ate that arg, and returned `{ config, lib, pkgs, inputs, ... }:`, line 3-onward, which is a module
<clever> matthewcroughan: when you did `import ./matthew self`, you passed it a copy of self
<clever> matthewcroughan: passing the inputs from the self that just one module gets, to every other module
<clever> from which default.nix?
<clever> so _module.args.inputs = self.inputs; and your done
<clever> and this is an HM module
<clever> matthewcroughan: so the self in here, contains a self.inputs
<clever> matthewcroughan: note here, you are passing the flake "self" to matthew/default.nix
<clever> matthew = import ./matthew self; # pass 'self' in order to allow ./users/default.nix -> ./users/matthew/default.nix to access ${self}, to provide a path relative to flake.nix.
<clever> yeah, i dont use flakes much yet
<clever> yeah
<clever> modules and imports can take files, lib.evalModules will import for you
<clever> also, dont use import there, that makes the error messages worse
<clever> modules = [
<clever> (import ./hosts/t480/configuration.nix)
<clever> i dont use home-manager, so i dont know the asnwer exactly
<clever> how do you then pass home-manager an HM module, from nixos?
<clever> matthewcroughan: line 28-32 is a nixos module
<clever> you must set it, from a context which does have access
<clever> that lets any module add args, which are then consumed by all modules
<clever> _module.args.inputs = inputs;
<clever> so youll need to go the other route
<clever> and it doesnt let you customize specialArgs
<clever> check the source, grep it for evalModules
<clever> you need to find out where home-manager calls lib.evalModules, and if it allows setting specialArgs
<clever> it gets passed thru to the lib.evalModules function, which takes a list of modules
<clever> but you need to add it to the specialArgs of home-manager too
<clever> so you can do " { config, pkgs, inputs, ... }:"
<clever> yeah, this line adds inputs to the args for every module
<clever> the 1st one, would use inputs.inputs.firefox, assuming the arg is passed the same way
<clever> rather then putting all args into a set, that you then name inputs
<clever> that is an argument named inputs
<clever> { config, pkgs, inputs, ... }:
<clever> *looks*
<clever> from a file that has access to the inputs
<clever> matthewcroughan: a really simple example is to just set system.build.flake-inputs = inputs;
<clever> and stick the attrset in that option
<clever> simplest option is to create your own nixos option
<clever> the flake stuff isnt passed into modules like that
<clever> matthewcroughan: thats not where inputs comes from
<clever> { config, pkgs, self, ... }@inputs:
<clever> so shell.nix could fake inputs that the flake is exporting as outputs
<clever> but shell.nix can then do ${toString ./.} and be impure
<clever> everything that flake.nix&friends does, is from /nix/store via flake rules
<clever> builtins.getFlake (toString ./.)
<clever> oh, you can also load a flake in a shell.ix
<clever> that complicates it
<clever> ah, flakes are evaled from a copy in /nix/store/
<clever> and it will continue to work after you cd more
<clever> while `${toString ./.}` adds the directory the nix file is in, even if thats not the current dir
<clever> pc32_simplekernel then inverts it
<clever> and the "pc" platform has this comment
<clever> 6 # Build whatever possible as a module, if not stated in the extra config.
<clever> 7 kernelAutoModules = true;
<clever> it gets fed into this line of a perl script
<clever> pkgs/os-specific/linux/kernel/generate-config.pl: $answer = "m" if $autoModules && $alts =~ /\/m/ && !($preferBuiltin && $alts =~ /Y/);
<clever> Ke: i think so
<clever> to see why foo is rooted
<clever> you can also `nix-store --query --roots /nix/store/foo`
<clever> if you wanted something fancy like a router in qemu
<clever> and the host would need to create one bridge per interface
<clever> and then bridge each into a diff host interface
<clever> not really, you would have to create multiple virtual interfaces, which get new names
<clever> that could also work
<clever> nf: services.qemuGuest.enable looks like a nice and clean way
<clever> nf: you could mkIf off anything in the config tree, starting on 529
<clever> nf: build-vm will include this module into your nixos build: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/qemu-vm.nix
<clever> "it booted windows, ship it"
<clever> sb000: ive also heard of machines that entirely ignore efi vars, and just boot the .efi file windows used
<clever> you can confirm it worked, with efibootmgr -v again
<clever> sb000: i think you want -o, to change the BoorOrder to only include 2
<clever> -o | --bootorder XXXX,YYYY,ZZZZ
<clever> -a -b2, will let you modify #2
<clever> what cmd did you try?
<clever> well, its not bricked :P
<clever> probably the bios
<clever> you want to change the BoorOrder that `efibootmgr -v` lists
<clever> you just have to go into the bios and change the default (or use efibootmgr)
<clever> ahh, so it did work
<clever> oh wait, that was the first line you pasted
<clever> the print on 717 wasnt printed
<clever> sb000: what does `switch-to-configuration boot` print to the console?
<clever> which then tells grub-install to do the rest
<clever> 718 my @command = ("$grubEfi/sbin/grub-install", "--recheck", "--target=$grubTargetEfi", "--boot-directory=$bootPath", "--efi-directory=$efiSysMountPoint", @extraGrubInstallArgs);
<clever> 717 print STDERR "installing the GRUB $grubVersion EFI boot loader into $efiSysMountPoint...\n";
<clever> 716 if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both")) {
<clever> sb000: if any of those config params are different from before, or the env var was set, it forces a reinstall
<clever> 692 my $requireNewInstall = $devicesDiffer || $extraGrubInstallArgsDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_BOOTLOADER'} // "") eq "1");
<clever> 690 $ENV{'NIXOS_INSTALL_BOOTLOADER'} = "1";
<clever> 688 if (($ENV{'NIXOS_INSTALL_GRUB'} // "") eq "1") {
<clever> 689 warn "NIXOS_INSTALL_GRUB env var deprecated, use NIXOS_INSTALL_BOOTLOADER";
<clever> 47 if ($action eq "switch" || $action eq "boot") {
<clever> 48 system("/nix/store/0fizwf7p1qd5laazw5gy16y7j4a7jjl4-install-grub.sh $out") == 0 or exit 1;
<clever> sb000: boot.loader.efi.canTouchEfiVariables = true;
<clever> looks like you didnt update the efi vars
<clever> /dev/nvme0n1p1: UUID="7DBC-2698" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="27c99b08-455d-4dfe-a44f-6150cbc09ef8"
<clever> for me, this is the key line it prints
<clever> Boot0004* UEFI OS HD(1,GPT,27c99b08-455d-4dfe-a44f-6150cbc09ef8,0x800,0x100000)/File(\EFI\BOOT\BOOTX64.EFI)..BO
<clever> sb000: `efibootmgr -v` ?
<clever> sb000: legacy or efi?
<clever> sb000: `man nixos-rebuild` -> --install-bootloader
<clever> --install-bootloader, too late

2020-12-19

<clever> once bcma has been blacklisted, wl should just work
<clever> Alexey12: boot.blacklistedKernelModules
<clever> they say to edit the modprobe blacklist, but nixos automates that via ...
<clever> Alexey12: what if you do `rmmod bcma wl ; modprobe wl` ?
<clever> yep, missing there
<clever> Alexey12: and it doesnt appear in `ip link` ?
<clever> Alexey12: what does `lsmod | grep wl` say?
<clever> Alexey12: yep, there it is
<clever> 03:00.0 Network controller [0280]: Broadcom Inc. and subsidiaries BCM43142 802.11b/g/n [14e4:4365] (rev 01)
<clever> ,locate bin lspci
<clever> Alexey12: we want the pciutils lspci, that one gives much better output
<clever> Alexey12: and i can see that wl was loaded in your dmesg, but it only printed 3 things
<clever> this confirms that the module was called "wl"
<clever> result/lib/modules/5.4.64/kernel/net/wireless/wl.ko
<clever> [root@amd-nixos:~]# find result/
<clever> [root@amd-nixos:~]# nix-build '<nixpkgs>' -A linuxPackages.broadcom_sta
<clever> Alexey12: how does it show up in `lspci -nn`?
<clever> Alexey12: is it a pci or usb wifi chip?
<clever> ,locate BCM43142A0-0a5c-216d.hcd
<clever> [ 8.989503] bluetooth hci0: Direct firmware load for brcm/BCM43142A0-0a5c-216d.hcd failed with error -2
<clever> Alexey12: can you also pastebin the dmesg?
<clever> Alexey49: rebooting may help, some stuff only loads the first time the card is detected
<clever> and you must use config.boot.kernelPackages instead of linuxPackages, to make sure its for the right kernel version
<clever> Alexey49: kernel modules must go into that array in configuration.nix
<clever> #extraModulePackages = [ config.boot.kernelPackages.v4l2loopback ];
<clever> boot = {
<clever> and if you check `which --all psql`, youll see its hiding a second copy
<clever> restarting likely wont help
<clever> check `which psql`, where is it coming from?
<clever> winsome[m]: i think you can use the -h flag to force it to look in /var/run/postgresql
<clever> connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
<clever> [root@router:~]# psql -p 5432 -h /tmp
<clever> the default directory changed at one point
<clever> that problem usually happens if your client and server are different versions
<clever> winsome[m]: does your socket live in /var/run/postgresql, or /tmp ?
<clever> srwxrwxrwx 1 postgres postgres 0 Dec 19 05:33 .s.PGSQL.5432
<clever> [root@router:~]# ls -ltrha /var/run/postgresql/
<clever> should be shortly before the error msg showed up
<clever> winsome[m]: is there a connect() call that includes 6543 in it?
<clever> winsome[m]: what path is it connecting to? strace psql -p 6543
<clever> without binfmt-misc, you would have to manually run qemu-user-arm on the arm binary
<clever> and if you try to run a matching binary, the kernel will instead run that interpterer
<clever> you give the kernel a bit pattern+mask, and an interpterer
<clever> the key to that, is binfmt-misc
<clever> matthewcroughan: it lets me run arm binaries on an x86 cpu

2020-12-18

<clever> coyotechords: each user has its own list of channels, if you --add a channel without sudo, then it only impacts things ran without sudo
<clever> fuzzypixelz: i think you can -i 'runHaskell -Xsomething?'
<clever> yeah
<clever> and then add split to the list
<clever> a #! on a haskell file?
<clever> fuzzypixelz: how does your #! look now?
<clever> that will give you a ghc that has split pre-installed
<clever> '
<clever> fuzzypixelz: nix-shell -p 'haskellPackages.ghcWithPackages (ps: with ps; [ split ])
<clever> fuzzypixelz: which package was Data.List.Split in?
<clever> fuzzypixelz: or ghcWithPackages
<clever> fuzzypixelz: i generally use callCabal2nix

2020-12-16

<clever> not sure why 2.0.4 thinks its already built then
<clever> viric: .schema
<clever> if you run sqlite3 /nix/var/nix/db/db.sqlite, can you find it in the ValidPaths table?
<clever> does the path actually exist?
<clever> then you skip the eval
<clever> viric: you could reduce the logging, by running `nix-store --dry-run -r` on the .drv directly
<clever> viric: single or multiuser nix?
<clever> pjt_tmp: i think you want `nix-shell -p pkgname -I nixpkgs=.`
<clever> pjt_tmp: `nix-shell -A pkgname` gives you an env suitable for building the pkg, not an env with a built copy of the pkg
<clever> so just `nix-shell -A pkgname` would work
<clever> so it loads the default.nix in the current dir, and entirely ignores the NIX_PATH
<clever> however, you never said to actually load <nixpkgs>
<clever> pjt_tmp: that says to look for <nixpkgs> as ./nixpkgs first, which likely doesnt exist
<clever> tnks: you can also do AVR stuff without the arduino tooling
<clever> tnks: namespacing, same tools as docker and systemd isolation
<clever> tnks: the sandboxing blocks both network and filesystem access
<clever> energizer: did disabling firmware actually make the closure smaller?
<clever> and then add mkdir and cp commands to it as needed
<clever> you can add `installPhase = "echo foo";` to the drv to make it skip that
<clever> bbl
<clever> ah
<clever> KarlJoad: is it even building anything?
<clever> by default, it just runs `make install` and expects the package to respect the `--prefix=` that was given to configure
<clever> but the unpackPhase and src= can operate on tar and zip without any need to pre-unpack
<clever> pkgs.fetchzip does the same (and can be used on tar files)
<clever> KarlJoad: builtins.fetchTarball is special, it will strip that common dir, and put it in /nix/store/hash-source/
<clever> it will complain and fail if more then 1 thing was made
<clever> the default unpackPhase will compare the dir listing before and after, and cd into whatever it made
<clever> KarlJoad: it just unpacks to the current dir, and assumes the tar has a root directory for all files
<clever> hardware.enableAllFirmware = false; may also help
<clever> and rebuild top-level, it should be much smaller now
<clever> energizer: hardware.enableRedistributableFirmware = false;
<clever> energizer: yikes, 600mb for firmware!!
<clever> energizer: this gives you a much better idea of the closure
<clever> [root@amd-nixos:~]# du -hc --max=0 $(nix-store -qR /run/current-system/) | sort -h | tail
<clever> energizer: toplevel is what gets packed inside initrd, and makes it 645mb
<clever> energizer: build config.system.build.toplevel instead of kexec_tarball, and check its closure
<clever> energizer: you need to look at the closure inside the initrd, not of the script
<clever> then you need more ram, or a smaller closure
<clever> what about the initrd file in the image dir, read the kexec_nixos script to find its path
<clever> how big is final.gz?
<clever> does dmesg say anything?
<clever> energizer: that last screenshot looks related to ram, how much ram does it have available?
<clever> energizer: it just drops the temp file as extra.gz and final.gz, in the workign dir
<clever> *looks*