2017-04-21

<clever> nixo_: anything interesting in the journal when you run journalctl?
<clever> hodapp: renaming shell.nix to default.nix, and using a new shell.nix like this may help
<clever> hodapp: ah, so the source is just that big, even after removing .git
<clever> hodapp: after you enter that nix-shell, what does this command say at the end?, du -h $src
<clever> gchristensen: an rpi3 would have build-extra-platforms = armv6l-linux armv7l-linux aarch64-linux, while your thunderx's would just lack build-extra-platforms entirely (defaulting to the arch nix was built for)
<clever> gchristensen: so you can describe that to nix-daemon correctly
<clever> gchristensen: i really need to make a nix PR for https://github.com/cleverca22/nix-misc/blob/master/upgrade.patch
<clever> ahh
<clever> so it will depend on the cpu's in the build slave
<clever> ah
<clever> gchristensen: aarch64 is also backwards compatible with v6 and v7, so it should also be possible to make some tarballs for armv6 and armv7
<clever> hodapp: shell.nix and default.nix
<clever> hodapp: can you gist both files?
<clever> and symlinks called result
<clever> hodapp: it will ignore .git, .svn, .hg, and any .so or .o files when importing the source
<clever> hodapp: then shell.nix will override default, and null out the src
<clever> hodapp: you could make a default.nix that works with nix-build, then shell.nix would just be this: (import ./default.nix {}).overrideDerivation (old: { src = null; })
<clever> ericnoan: that reminds me, i need to get firefox 53 on my nixos, so i can update my extension
<clever> though i tend to keep src=, so i can also test with nix-build
<clever> unpackPhase is what gives the error about missing $src, and if you never run it, it wont fail
<clever> but you can omit src entirely
<clever> you still need to use stdenv.mkDerivation to get a compiler and make buildInputs function correctly
<clever> hodapp: you can also do src = lib.cleanSource ./.;
<clever> hodapp: its probably trying to snapshot the entire .git folder
<clever> hodapp: "warning: dumping very large path (> 256 MiB); this may run out of memory" is because the src = ./.; referenced over 256mb of files
<clever> more like 6 hours later, lol
<clever> hodapp: thats how i do things
<clever> and rm -rf is far easyer then implenting a perfect make clean
<clever> then the build dir isnt part of the source, so it cant mess up
<clever> oh, and since its cmake, you also have the option to mkdir ../foo-build; cd ../foo-build; cmake ../foo/
<clever> just remember to make clean, or the next nix-build will reuse the old .o's and make a mess
<clever> but if your using nix-shell, you can just skip the unpackPhase and directly configure the source you have checked out
<clever> each time you nix-(shell|build), the src = ./.; will copy a snapshot of the source to /nix/store
<clever> all that will do is copy the source from the nix store back to the current directory
<clever> unpackPhase is optional
<clever> and you can just change the src in each of those nearby files to src = ./.; to make it always use the current source
<clever> hodapp: this default.nix will return an attrset containing many derivations, and it will use callPackage to load each of them from other nearby files
<clever> hodapp: though if the project grows, you could do some other things, *gets examples*
<clever> hodapp: then you can leave it like that in general
<clever> spacefrogg: ah, i was looking for where it accepts multiple tokens for a list
<clever> hodapp: that also works, but makes it harder to .override things if left like that in nixpkgs
<clever> that looks like using ( and ) to force the order of operations
<clever> hodapp: ah, you can usualy just grab the whole default.nix, and replace line1 with this: with import <nixpkgs> {};
<clever> hodapp: and it will find the expression and just give a shell
<clever> hodapp: you should be able to just nix-shell ~/nixpkgs -A foo
<clever> joepie91: it will make a list with 1 function, and 3 values
<clever> joepie91: there are also some oddities that i dont think are documented well, list [ function arg1 arg2 arg3 ]; will not call the function
<clever> joepie91: also, the parser wont include the implementations of functions within the builtins attrset
<clever> joepie91: ah, further down in the docs: https://nixos.org/nix/manual/#ch-expression-language
<clever> jophish: ive got both docs and raw source!
<clever> because there can only be one /lib/libc.so
<clever> guides for things like musl say you need a whole chroot or docker instance just to mess with it
<clever> something a lesser OS cant even do, lol
<clever> though you will wind up with 2 copies of glibc and anything else it depends on
<clever> and it should get buku right from the binary cache and not have to build it
<clever> then it will use the unstable buku against the unstable version of its dependencies
<clever> then you may want to use the entire unstable like my last gist
<clever> and it may upgrade that set of packages without warning
<clever> only downside i can see with this method, is that it will re-download nixos-unstable every time you nixos-rebuild
<clever> infinisil: and you can move the let block to make it cleaner: https://gist.github.com/cleverca22/f65e9b4dfb168ada980edadb6717a167
<clever> environment.systemPackages = let pkgs-unstable = import (builtins.fetchurl https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz) { config = {}; }; in [ pkgs-unstable.hello ];
<clever> you can also store the nixpkgs in a variable if you want to make it cleaner or refer to several things
<clever> this will download the hello world package from nixos-unstable
<clever> environment.systemPackages = [ ( (import (builtins.fetchurl https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz) { config = {}; }).hello ) ];
<clever> so you could do this
<clever> this will use the current state of nixos-unstable for the entire closure of whatever you use
<clever> so the result will be a mix of 2 channels
<clever> this will use the nixos-unstable expression for glfw, but build it against libraries in the current channel
<clever> 2016-09-20 15:52:46< macslayer> (callPackage (builtins.fetchurl "https://raw.githubusercontent.com/NixOS/nixpkgs-channels/nixos-unstable/pkgs/development/libraries/glfw/3.x.nix") {})
<clever> i'm checking my irc logs to find more
<clever> there are other URL's to pick from
<clever> let pkgs2 = import (fetchTarball https://github.com/NixOS/nixpkgs/archive/2766a4b44ee6eafae03a042801270c7f6b8ed32a.tar.gz) { config = {}; }; in { ....
<clever> infinisil: yes
<clever> simpler to just do it in 2 passes, image->card, spl->card
<clever> ben: i have thought about how to configure watchdog stuff to handle events like that
<clever> i almost always dd to block devices, so ive never seen it do that before
<clever> *doh*, dd truncated the file!
<clever> -rw-r--r-- 1 root root 491K Apr 21 12:59 sd-image-armv7l-linux.img
<clever> there is a pad for a config eeprom, but its not populated
<clever> Dezgeg: and on that subject, the switch IC defaults to putting the wan and lan in the same vlan!
<clever> lol
<clever> and if you can fit DRAM + SATA code into 32kb, you could load the u-boot from sata
<clever> so if you mount an eMMC chip on the MMC0 bus, and never corrupt the SPL header, the end-user cant boot their own firmware
<clever> and i think all of the security of the bootloader is based on the priority system alone
<clever> i have not seen any mention of fuses in this board yet
<clever> it would also help if i wire the rx pin of the uart up, lol
<clever> and it has a sata interface, so the nixos could just be on a regular old hdd
<clever> it also supports loading the SPL+u-boot from nand flash, spi flash, or 2 different sd card busses (only one is mounted)
<clever> yeah
<clever> [root@amd-nixos:~]# dd if=/nix/store/lc3p1izbx9fdcc6wyjsqrp461djl5ry4-uboot-Bananapi_defconfig-2017.03/u-boot-sunxi-with-spl.bin of=sd-image-armv7l-linux.img bs=1024 seek=8
<clever> just need to figure out where i left the u-boot build, and i can give it a spin
<clever> ah
<clever> i believe the entire 8kb to 672kb range of the image needs to be available
<clever> depending on your partition layout, i could just dd that u-boot to the correct offset
<clever> Dezgeg: it needs a bootloader with an SPL at a specific offset on the sd image
<clever> jophish: the user that will be doing the bulk of the use of nix must have write access to /nix/store
<clever> jophish: https://github.com/NixOS/nix/blob/master/scripts/install-nix-from-closure.sh normally handles that, in the install.sh case
<clever> just need to copy that nix to the arm device, and initialize the database
<clever> and there is an armv7 build also
<clever> jophish: so you could just patch the install.sh to use my tar, and your done
<clever> jophish: i already have my hydra building the tarball that curl install.sh would need
<clever> Dezgeg: so far, i have u-boot running, and my next goal is to throw a kernel at it and see what happens
<clever> Dezgeg: oh, and ive been looking into porting nixos to an A20 based processor, http://www.banana-pi.org/r1.html
<clever> ah, some of the info ive been reading is also repeated under https://github.com/torvalds/linux/blob/master/Documentation/arm64/booting.txt
<clever> though i havent tried to build it there
<clever> i would expect it to work on arm
<clever> i thought it would be simpler to just redo the entire testing framework in UML linux, lol
<clever> i had similiar problems months ago when i was trying to get armv7 nixos
<clever> yeah
<clever> i believe gchristensen has access to real aarch64 hardware, so that shouldnt be an issue
<clever> ah
<clever> Dezgeg: the problem is nixos testcases, they all rely on qemu
<clever> Dezgeg: i think qemu defaulted to enabling el2 and el3, but nixos has no need to emulate the hypervisor or secure monitor levels
<clever> spacefrogg: yeah, you either need to turn el3 off with the above flag, or turn kvm off
<clever> Dezgeg: a stackoverflow i found implied that it needed -machine secure=off,virtualization=off, to remove el2 and el3 support
<clever> spacefrogg: and el3 was enabled by default, and needs a 2nd address space
<clever> spacefrogg: the original problem me and gchristensen ran into, is that kvm doesnt support multiple address spaces
<clever> spacefrogg: and you can restrict all access to any part of the cpu, so the untrusted levels cant reconfigure things
<clever> spacefrogg: and the software in el3 essentialy has its own view of physical memory, completely isolated from everything else
<clever> spacefrogg: el0 is userland, el1 is kernel-space, el2, is hypervisor, and el3 is the secure monitor
<clever> spacefrogg: and they work a lot like ring0 in x86
<clever> spacefrogg: the armv8 has 4 exception levels, el0 thru el3
<clever> gchristensen: and it was 1 page up in the tree from the page i started on yesterday! lol
<clever> infinisil: there is also "nixos-rebuild build-vm" which can spawn the entire config in a qemu vm, and leave the host untouched
<clever> gchristensen: heh, only now do i find out what the el in el3 means! http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch10s02s04.html
<clever> that would also explain it not working under nginx
<clever> neat, the cpu will basicaly lie about pages existing, so there is no way to tell the difference between unmaped ram, and "secure" ram
<clever> and qemu implements it as a seperate address space, more like a harvard architecture
<clever> gchristensen: ah, it sounds like the arm has an extra bit on the address bus, to signal secure/non-secure
<clever> 'This additional address bit gives a physical address space for the Secure world and a completely separate physical address space for the Normal world.'
<clever> nor would you need to be aware of the partitioning when configuring paging
<clever> gchristensen: it almost sounds like the hardware has 2 different views of 'physical addressing', so you cant even bypass things with paging tables
<clever> gchristensen: reading the arm docs more, it looks like trustzone is implemented in EL3, and going by the qemu source, that has its own address space that it lives in
<clever> i think nginx will pass it on if you dont explicitely configure auth in nginx
<clever> so nginx will allow/deny based on auth, but radicale wont even know auth is in-use
<clever> but radicale wont know what user you auth against
<clever> 'A server error occurred. Please contact the administrator.'
<clever> https://dav.infinisil.io/bob/birthdays.ics/ should do something, if that calendar/user exist
<clever> correct
<clever> which defeats the whole point of running it
<clever> opening port 5234 allows you to bypass the proxy
<clever> only if you connect to a port the proxy is listening on (80 or 443)
<clever> infinisil: so you need to remove an s from the https://
<clever> infinisil: radicale is not doing ssl
<clever> disasm: the domain also appears to be publicly accessible, so you can just test https://dav.infinisil.io/
<clever> websocket and raw tcp are not allowed, but websocket can be added
<clever> but it can only pass http traffic
<clever> infinisil: when nginx gets a request on port 80 with the Host: header set to dav.infinisil.io, it will internaly relay the request to http://127.0.0.1:5234
<clever> the firewall isnt allowing 5234 for remote access
<clever> via localhost or remotely?
<clever> and https://dav.infinisil.io/ claims "Radicale works!"
<clever> looks like that should be working
<clever> and it will configure 3 sites in nginx, and install vim
<clever> so configuration.nix can contain imports = [ ./site1.nix ./site2.nix ./site3.nix ./vim.nix ];
<clever> you can list as many nixos modules as you want in the imports of any module
<clever> and you can do that from several different nixos modules, and it will just inteligently merge all of them into a single nginx config
<clever> this sets up a vhost with an automatic ssl cert
<clever> infinisil: let me throw together an example
<clever> infinisil: ive found the nginx stuff in nixos to be great
<clever> infinisil: ive done similiar for some servers i'm setting up, and ive written testcases that can spin up a fresh vm purely from the config, and run tests against the software
<clever> infinisil: https://pastebin.com/9M2jiHmp this gets loaded by configuration.nix, and embeds my vimrc into the vim package, while also providing some defaults for env variables (line 37-40)
<clever> infinisil: depends on if the package allows it or not, some things like vim and emacs let you embed the user config into the package
<clever> infinisil: then i can just nix-env -iA nixos.mystuff, and it will atomicly update the profile to match the current config
<clever> infinisil: it loads some custom packages, then defines a custom package called 'mystuff' that is the result of merging many packages
<clever> infinisil: https://pastebin.com/DvasmCLD this is the start of my ~/.nixpkgs/config.nix file
<clever> engblom: haskellPackages.xmonad-contrib
<clever> engblom: every single package on hackage is available as an attribute under haskellPackages
<clever> engblom: you should be able to add haskellPackages.xmobar to environment.systemPackages
<clever> Infinisil_: cant think of an answer to that
<clever> engblom: haskellPackages.xmobar
<clever> without waiting for you to finish with things
<clever> Infinisil_: it will move to the next step, which is terminating the entire session
<clever> Infinisil_: is .xsession executable?
<clever> Infinisil_: you can also configure most irc clients to auto-join and auto-connect
<clever> i mainly stick to irssi
<clever> then you can just fill in your own session script
<clever> which will run xterm as your session, then terminate the script i previously linked from github
<clever> engblom: you could get the same effect by doing services.xserver.displayManager.sessionCommands = "xterm ; exit";
<clever> engblom: if you +x it, then nixos will just run it by default
<clever> i have looked into automating that more in all of nixpkgs
<clever> it also has to rebuild glib with static enabled
<clever> LexLeoGryfon: here is a package i made a while back, to compile qemu staticly
<clever> but it still wants ncurses, and fails to build
<clever> nano.h:96:20: fatal error: curses.h: No such file or directory
<clever> LexLeoGryfon: this override just builds nano without giving it a copy of ncurses
<clever> nix-repl> :b nano.override { ncurses = null; }
<clever> [clever@amd-nixos:~/apps/qemu]$ nix-repl '<nixpkgs>'
<clever> FRidh: simplest thing i can think of is just pushd foo; unpackFile; popd
<clever> nix keeps all of the dynamic libraries you depend on as read-only, so there is no real difference over a static build
<clever> the static binaries are larger, and when nix is doing its job, give you no added benefit
<clever> LexLeoGryfon: why do you need a static build of nano?
<clever> FRidh: yeah
<clever> FRidh: and it will compare the dir listing before&after, to figure out what sourceRoot is
<clever> FRidh: it will unpack to the current directory, and then cd into that directory
<clever> LexLeoGryfon: static isnt an option, and ncurses doesnt appear to be optional
<clever> TweyII: nix-shell will also bring gcc and binutils in, so no need to install those globally either
<clever> TweyII: that will do for most projects
<clever> with import <nixpkgs> {}; stdenv.mkDerivation { name = "foo"; buildInputs = [ pkgconfig openssl ]; src = ./.; }
<clever> TweyII: you can always upgrade the dummy to a full expression at a later time
<clever> TweyII: either a dummy shell.nix, or a full default.nix
<clever> nix just isnt meant to be used like that
<clever> this is why i always tell people to never install build-time utils like gcc, ld, pkg-config, and so on
<clever> TweyII: that will load this setup-hook, which scans $buildInputs, and adds it to the pkgconfig search path
<clever> TweyII: you must also add pkgconfig to the packages
<clever> tjg1: yeah, that would also help
<clever> TweyII: seems to work when i do it: https://pastebin.com/jtkG9hQc
<clever> Guest8704: and your fighting nickserv some
<clever> Guest43251: nix-shell -p openssl
<clever> tjg1: ah, that could be an issue
<clever> avn: if we symlink /swap to /dev/zvol/tank/swap, then the stage-1 scripts will think its a swap file, and ignore it, but stage-2 will follow the symlink and use the zvol
<clever> avn: it thinks the hibernation image is on that swap, and wants to resume it before mounting too much
<clever> avn: hence the symlink to a zvol
<clever> tjg1: but once you boot, it follows the symlink and uses the zvol!
<clever> tjg1: then the safety on line 209 of stage-1.nix will think your using a swap file
<clever> tjg1: what if you make a /swap symlink to /dev/pool/swap
<clever> tjg1: oh, i just had a thought
<clever> that also works
<clever> tjg1: if you dont mind reinstalling, it might be better to change the layout to be more like my laptop
<clever> tjg1: setting randomEncryption on the swap device might solve the problem your having, but then it will be double-encrypted
<clever> i was expecting zvol swap issues, and used lvm to avoid them
<clever> in my laptop, it is
<clever> so a single passphrase protects the entire lvm array (swap + zfs)
<clever> CMCDragonkai: the swap is on lvm, and the PV for lvm is on luks
<clever> with the negative that the swap can be recovered if you have the passphrase
<clever> so i would expect the swap->lvm->luks to have the same performance as swap on randomized luks
<clever> i wouldnt expect lvm to add much overhead
<clever> CMCDragonkai: the machine is nearly a decade old, so its hard to tell
<clever> CMCDragonkai: i went with zfs+swap on lvm, with the lvm on luks, just to avoid the zvol swap issue
<clever> tjg1: it must start with /dev, it must not have randomEncryption, and it must not be a zram
<clever> tjg1: the s variant is the result of running a map and filter over the swap devices
<clever> tjg1: if it is an empty string, wait for everything in resumeDevices (with an s)
<clever> tjg1: if resumeDevice (no s) is a non-empty string, wait for it to appear
<clever> tjg1: it wants to load the hibernation state from the swap, and ive heard something about hibernation on zvol not working either
<clever> tjg1: ah, i suspected it, its waiting for the resumeDevice
<clever> gchristensen: this answer says how to enable secure mode, so lets just invert it, -machine secure=off -machine virtualization=off, this should remove EL3 and EL2 support
<clever> tjg1: i dont think stage-1 is responsible for enabling swap, can you screenshot the problem?
<clever> gchristensen: still looking thru the code to find that
<clever> then kvm will work
<clever> gchristensen: so we should be able to turn el3 and el2 off safely
<clever> gchristensen: i think EL3 is to do with the secure monitor, and EL2 is to allow a hypervisor inside the vm
<clever> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.den0024a/ch10s02s04.html
<clever> gchristensen: and it can be turned off somehow: https://github.com/qemu/qemu/blob/master/target/arm/cpu.c#L729-L740
<clever> gchristensen: has_el3 seems to be the trigger
<clever> gchristensen: i think cpu_address_space_init was called with an address space index greater then 0
<clever> /* KVM cannot currently support multiple address spaces. */
<clever> assert(asidx == 0 || !kvm_enabled());
<clever> also of use, add "-o json" to journalctl, to see all the internal fields
<clever> the only thing you could do to filter it more is to filter based on the contents of the message
<clever> tjg1: this filters it some
<clever> [root@router:~]# journalctl -f -t kernel SYSLOG_FACILITY=0 PRIORITY=6
<clever> tjg1: it already goes to the journal
<clever> [root@router:~]# journalctl -f -t kernel
<clever> -- Logs begin at Sat 2017-01-07 23:05:40 UTC. --
<clever> Apr 21 11:27:35 router kernel: rejected connection: IN=wan OUT= MAC=00:30:48:c5:d2:de:08:81:f4:e5:bf:c2:08:00 SRC=139.162.96.165 DST=47.55.132.219 LEN=60 TOS=0x00 PREC=0x00 TTL=54 ID=58426 DF PROTO=TCP SPT=31421 DPT=8333 WINDOW=29200 RES=0x00 SYN URGP=0
<clever> since we are running qemu-system-aarch64, its likely to force aarch64
<clever> which is pretty close to the rpi3 layout
<clever> it might emulate the hardware layout of the rpi2, with an aarch64 cpu
<clever> raspi2, virt(|-2.6|2.7|2.8), all look like good candidates
<clever> gchristensen: https://pastebin.com/zsysvdiY
<clever> so i can now test things on x86
<clever> and this gives my machine the ability to run aarch64 code
<clever> this downloads the exact same qemu build from the cache, and roots it in the current dir
<clever> [root@amd-nixos:~]# nix-store -r /nix/store/q0mpsx8wlpklinzfhx6yf5bsw1780b4q-qemu-for-vm-tests-2.8.0 --add-root qemu-aarch64 --indirect -Q -j8
<clever> ok, ive confirmed that it is an aarch64 qemu, built against aarch64
<clever> this kind of mess is also why i was looking into UML linux for the nixos test framework, it seemed simpler then fixing qemu
<clever> from what ive read, you can make a kernel that has a range of drivers linked in, and pass it a DTB that describes what hardware is actualy present, and which drivers to point at what addresses
<clever> as will device-tree
<clever> the bootloader like u-boot can help to even that out some
<clever> and the boot process and hardware layout is far less standardized on arm, so the kernel is tightly coupled to how you make it boot, and what qemu has to emulate