musicmatzes blog

linux

Finally I got NixOS installed on my Thinkpad as well. I created a wallpaper for the device, which I want to share here.

Another blog post about the switch on my Thinkpad will follow.

So here we go:

NixOS wallpaper

As you can see, I'm not really good at designing wallpapers.

Feel free to customize my gimp project, if you want: GIMP project file.

LICENSE: The above files (the wallpaper image and the GIMP project file) are available to you under terms of the terms of WTFPL. Everything else remains under the license of this blog, though.

tags: #linux #nixos #nix

So I (re)installed NixOS on my old Notebook yesterday and today. Besides some small problems it worked like a charm. Read about it here.

Why did I reinstall?

Well, the old setup was fine. Besides one thing: I hadn't my configuration repository on the device. You may think, well, where is the problem? Just install git and clone it from the other machines, right? The point is, I like to keep my configuration parts private and only share snippets of it if someone asks. Also because there are passwords in it and so on. You know what I mean.

That's why I need disc encryption when I want to clone my configuration repository on a device. So I had to reinstall the device because it had no disc encryption. No problem, as nixos is awesome!

The process of reinstalling

Well, it was really simple: Boot the USB stick, format the drive with fdisk and create encrypted volumes with cryptsetup, then mount them and create file systems with mkfs. Then mount these and do a nixos-install – smooth as hell!

After that, I edited the configuration.nix file which was created by nixos-install, so had vim and git available when rebooting – also smooth as hell.

But then, I did the big mistake.

The problem

I was a bit tired yesterday, so apologies here. But I actually did adduser. Of course, it worked for the first step. I then logged in with this user, edited the configuration.nix file to have the user as well, rebuild the system and rebooted. The user still existed, but the packages were not available. I had already cloned my configuration repository onto the encrypted drive and linked it from the /etc/nixos/configuration.nix path, but the packages were not available to the user.

The solution

The solution I found this morning was rather simple: I had two boot loader configurations in my configuration files, as my workstation machine boots via gummiboot for UEFI but the old notebook had to use grub. Two bootloader definitions are not that good – the bootloader didn't get any updates, so I always rebooted into the same generation, resulting in a way to old environment, where the packages were not available.

I fixed this one and also removed everything which was related to the user I had created. I did a nixos-rebuild switch. The user got created, the bootloader got its update.

Everything worked.

Awesomeness

So, overall, you can reproduce by:

  • Don't be tired when installing a OS
  • fdisk
  • cryptsetup
  • mkfs
  • mount
  • nixos-install
  • vim
  • nixos-rebuild

in this order.

And you have everything available. It is SO awesome. I just logged into the machine over SSH and did some things. It was SO easy, because I didn't need to reinstall all my stuff, I already had it available and it worked. That's pure awesomeness to me (pun intended)!

tags: #linux #nixos

This semester is at its end in about one and a half week. It was a good semester, even if mine is not over yet (I'm in my praxis semester right now and I have to work four weeks longer than the other students – but they have exams)! Since one year I'm the leader of the local LUG (Linux User Group) and I really like beeing it.

As far as I can tell I will be the leader for the next semester as well, but I guess one year is a great point to reflect and look back what I've done and what was awesome and maybe even what was not so good.

What was

So, in the last year, we had (during the semester) one talk each week (in alphabetical order here):

  • 31C3-Review
  • C++ – Arcane and rusty (2 parts)
  • Docker
  • Email (In)Security
  • FTP-Searchengine
  • Fish
  • Git-Intro
  • Go
  • Nix(OS) (my talk, actually)
  • Pimp my x86 (2x)
  • Presentation of a Bachelors Thesis
  • Presentation of a semester project (2x)
  • Racket
  • Regex Workshop
  • Reverse-engineering Workshop (2 parts)
  • Ruby on Rails 1
  • Ruby on Rails 2
  • Rust

Almost all talks were held by students, only one was help by an ex-student, who does one talk each semester for us. And they were awesome.

We also managed to go to the 31C3 as a group, which was an awesome experience and I'd really love it if we manage to go there this year as well. I also started a rewrite of our website, hopefully I will finish it this weekend, so I can do a talk about it next week, which is the last week where a talk is held in this semester (traditionally we do a “Pimp my x86” talk at the very end of the semester, where each student is allowed to talk for about 10 minutes, so it is lightning-talk-ish).

Plans

So next semester I really want to start organizing for the next Unix Friends and User Campus Kamp (Yes, the shortcut for this is UnFUCK). I really hope we can manage to get this event in the following semester, in the early months of 2016. It would be awesome to have a full weekend of nerdish talks and awesome people hanging around in our university, talking about Linux, programming languages and other foo which scratches my fields of interest.

And, of course, I hope we have some more awesome talks.

tags: #linux #open source #programming #social #software #tools

Yesterday I was at tübix in Tübingen, Germany. And it was awesome, thank you guys for making this event happening!

There were several really interesting talks for me, starting with, of course, a talk about NixOS, held by a NixOS guy I didn't knew by then. Joachim was there, too, and we had a nice chat about but not limited to NixOS! Thank you for beeing great, Joachim!

Afterwards I attended the talk about mutt and gpg, which was held by Sven, a really nice and inspiring guy who likes colors.

Afterwards I switched to the lightning talks, where I arrived just in time to see Ingo talking about Haskell. Oh my god, I really like this guy! He was really charged with energy when he started talking about Haskell. Awesome! I had a little chat with him afterwards about how to learn Haskell, as I still have some problems (not with Monads, as he assumed first, but) with getting the theory to do practical things for me. Thank you for the nice time, Ingo!

After some pizza, which was really tasty, I learned about pandoc from Kurt (no link here, sorry). And with this talk, I got to learn about a tool which I can use to write my thesis, so big thanks to Kurt for this! We also had some short chats where I learned even more about Pandoc and what it is able to do! Thanks a lot!

Then I went back to the room of the lightning talks, where several LUGs presented what they are doing and so on and I was forced to talk about UnFUCK without further preparation. I don't mind it, thank you all for listening and giving me the opportunity to talk about the Unix Friends and User Campus Kamp at my University!

Then I went to a talk about Network Steganography held by my former fellow student Florian. Thank you, too, Florian, I've learned another bunch of things, so: Success!

After that I saw some notes from Joachim on nice stuff from the net and a talk about functional programming in C++ which was more or less a selling talk for Haskell. I don't mind it, of course. It convinced me even more not to get an C++ programmer, because holy shit, this language sucks!

The exit talk was nice as well and afterwards we had some more time to socialize and talk with people and so on. But then we had to drive home again. It was an absolutely awesome day and I'd really love to be there again in 2016! Hopefully this was not the last tuebix!

tags: #social #software #linux #nixos

So I'm in my praxis semester at the moment, and I have to work with fastcgi++, a C++ library for fastcgi. And it is a nightmare! Here comes why...

So first, the codebase of fastcgi++ is a mess. Code snippets like

bool foo = someFunction();
if (foo) return true;
else return false;

are everywhere. You really don't want to read that kind of code. And yes, you have to actually read this code because there is no documentation on how to use the library! There is a wonderful doxygen-generated API documentation, but that does not help you because, yeah, you know the types and the interfaces now – lucky you! How to build a fastcgi module with them – figure it out by reading through the codebase!

Secondly, you are not allowed to define your custom accept() handler. You have to inherit from a Request class template and you have to implement the virtual bool response(void) = 0; method. Okay, no problem, I can do this! But then, you want to start accepting requests. You do this by creating an instance of a class called Manager:

Fastcgipp::Manager<MyRequestInheritedClass> man();
man.handler();

or something like this (this is no real code, I just want to demonstrate how it looks like). The manager accepts one connection (through many layers of abstraction, actually), creates an instance of your request class and calls response() on it.

Well, that's not a problem, is it? Well, it gets to a big problem if you want to be able to handle multiple requests at once, speaking of multithreading/concurrency here. It is a huge mess! My codebase exists of three classes, actually. A ThreadedRequest class, a BlockingQueue where requests get stored thread-safe and a RequestDispatcher which is a singleton which runs several worker threads. These worker threads take the requests out of the queue and process them if they can.

The ThreadedRequest class puts itself into the queue, which is a member of the RequestDispatcher singleton instance. The problem is not that it is unnecessarily complicated to build these 1-N multiplexing thing, but that the library provides an interface which enforces you to couple your classes realy tightly. And this is freaking bullshit.

So, finally: I'm building a wrapper lib around fastcgi++ to be able to handle requests in a concurrent way. And it sucks. But it works.

So, my conclusion is: Stay away from this bullshit library. And even from fastcgi if you can. Apache for example offers a way to write modules, so you can simply write your own module for apache if you need to – which is faster anyways!

If you have to use fastcgi, consider writing your own library!

tags: #c++ #linux #server #open source #programming #software

Really, just stop it! Nobody benefits from all your new Linux distributions, if they don't change a major thing!

Why am I posting this? Well, yesterday, another Linux distro was announced on a german news site called “heise”. OzonOS is shown as nice-looking new linux distro on top of Fedora. It comes with Atom Shell, optimized for consuming media like music, videos or games.

But well ... so what? We already have a buttload of linux distributions and these are only the ones listed at wikipedia. There are much more, I'd bet on it! But who benefits from even more linux distributions? I can tell you who: Nobody! Why not improving existing linux distributions? I mean, yeah, if you have a completely new approach on how to put together your distro, like Guix or NixOS have, I don't say a thing! But just because of user experience? It seems like a freaking waste of effort to me!

So please, people, stop making new linux distributions! Make the existing ones better, improve our beloved open source software or whatever! But don't waste your time on something like another linux distro or desktop environment or browser or office suite or whatever!

tags: #linux

This part is about running (as far as I think) insecure applications on NixOS. How'd you do that? Well... my approach is docker!

Read it here.

So, docker. I learned from docker when it was introduced. I guess it was two years ago or something like that. I never used it, though. But today, I use it. And I use it on NixOS!

The first thing you have to do is to put

  virtualisation.docker.enable = true;

into your configuration.nix file. Of course, you also have to install it. This depends on where you want to use it, so put it either in your systemPackages configuration or install it in your user profile with nix-env -i docker or, if it works (I didn't try) with nix-env -iA pkgs.docker to be a bit faster.

Be sure your user is in the "docker" group! This one is really important. I actually had a bit of an issue (well, “a bit” is well said, I couldn't run anything... so I had a big issue) with docker because I forgot to put my user into this group.

After the last step, you have to logout and login again.

So, now you should be able to run docker containers! I found a blog post by Jessie Frazelle, where she explains how she runs, for example, lynx in a docker container. She also provides examples for how to run chrome in docker, including google talk plugin!

Other stuff she shows:

  • skype
  • spotify
  • gparted (huh?)
  • tor browser
  • mutt
  • irssi

Awesome, huh? You can not run Skype as container! This is awesome. I won't do it, though. Skype is still spyware! Also remember: docker is not to run apps which are eventually evil. Especially not if these apps can access the X server!

Jess has also a github repository where she stores docker files for much more applications:

  • atom
  • chromium (I'm running chromium, not chrome, actually)
  • mailman
  • transmission

... to name a few.

tags: #linux #nixos

I've done it. This blog post is written from my NixOS installation on my new machine. Have a look inside to see a screenshot and my experience with the actual setup of a real machine with NixOS.

So, the setup is not that simple, so I ran into some issues, of course. But maybe I should list my hardware first, at least the relevant parts:

  • Processor: AMD FX-8320 (8 x 3,5 GHz)
  • Graphics Card: MSI AMD Radeon R9 270X Twin Frozr 2GB GDDR5
  • Motherboard: Gigabyte GA-990FXA-UD3

Plus two 3TB WD drives and a 120 GB Samsung EVO SSD. I guess the other parts are not relevant here and now.

Configure all the things!

I started by doing a simple NixOS installation, everything worked. Then I restarted it and encrypted the drives. This got me into some trouble, because it did not work that simple. After booting with the appropriate settings (for encryption), the bootloader was shown and after that there was just nothing shown. It was really scary! After adding the ext4, dm_crypt and the fbcon (which is for message printing during early boot) I got the password prompt from luks, so everything was fine from there. I had to play around with the actual cryptdevice configuration, but I got it working really fast. After that, I simply copied my configuration.nix over to the machine and tried to rebuild the system. It failed. But it failed because of a simple reason: I added a 900,000 lines /etc/hosts entry to my nix configuration before copying it over to the machine. That was a bit too much, so I had to comment it out.

I'm running on NixOS for a few weeks now and I still have some problems, but they are all very specialized ones. For example, I use youcompleteme as autocompletion engine for vim. But it cannot find the standard headers, as these are obviousely not installed in /usr/include! That's one of the issues I can remember at the moment. But hey, it works!

tags: #linux #nixos

Some of you might know my little project rate. It is a bash script to collect a database of things you want to rate.

What this means and why I started to reimplement in C++ – read it here!

So I started to write this application because I wanted to keep track of animes I already watched, Bands I like but do not listen to that often and so on and so forth. What the application does is really simple: You can enter notes about a certain thing (in your favourite text editor, which is vim for me) and attach tags to it and put it into a category. Then you can give it a rating. The rating can be everything, from simply numbers to text to whatever you like. But it is supposed to be a number between 1 and 10, of course. That's also the way I use it.

So how does it work? Well, that's really simple: The “rate” script creates a directory structure in ~/.rate/collections/, whereas a folder is a “collection” of things and a file is a rating. So, I have something like “movies/animes/” as collections (they are nested, of course) and then a file for each anime I watched. The filename is generated from the title I passed “rate” when creating the entry. The file also contains a “header”, which includes a unique ID (which you really should not change), a list of tags, the title (the filename is the title, too, but as on linux you shouldn't include whitespace in file names, it is not the title as you typed it) and a rating of course. Custom fields could be added to the header, but this feature is not implemented yet. After the header, you can put your description.

That's basically it. “rate” provides some features to search this database, for example you can grep for text in your entries, you can view your entries, you can list your entries and you can attach more text to your entries or edit them. As everything is git controlled in the ~/.rate directory, you can reset if you (or the script,...) messed up somehow.

There's no release by now, as it lacks of some features by now. For example I want to be able to search for entries with a certain rating or within a certain range of ratings. I also want to be able to search for entries with aspecial set of tags or within a certain collection (I can do this, though) special set of tags or within a certain collection (I can do this, already)! After these things are implemented, I will release my first version, which would be 1.0 then. And, of course, I will package it for NixOS!

So why C++

Well, I have to learn C++ for my praxis semester. That's basically it. I wanted to learn a new programming language for a relatively long time, and that's my approach on learning C++. I was able to implement some things, but not yet to run an application. My first step would be to parse my already existing entries. Hope that works. As I stated in the github repos README.md file, I do not want to use any frameworks for this. No Boost, no Qt, no other libraries. I just want to use plain C++11 (or maybe 14 in future, not sure about this, though).

Also, C++ gives me way more posibilities when it comes to features. I can refactor things really easy and maybe the C++ implementation will continue to live whereas the bash implementation will die at some point. Who knows? The point is, the bash implementation implements a file format which is

  1. really simple
  2. forward compatible

The file actually looks like this:

key = value
other = value
another = another
---

<text>

and that's basically it. The three dashes mark the end of the header and everything before the header is a <key> = <value> list, whereas each line is only allowed to contain one key-value-pair. The value can be a list of values, for example a list of Tags whereas tags are seperated by a whitespace character (space) or a string, such as the title is. The bash implementation “knows” which key has to be which value and the C++ implementation has to know this, too, of course. But that's it.

The commandline interface of the application needs some work, though. Maybe it will get some REPL-like interface later on, or maybe something more interactive. By now, it is simply an interface where you can do one thing per call. I have no problem with that and I'm planning to keep backward compatibility with the bash implementation even if this one is not even released! It is fun to write such a tool and I really like doing it.


Also, it is not a that complex thing to implement and that's a huge point to me. I don't want to spend months and months in implementing a thing which only one or two people on this planet actually use. For bigger projects, I contribute to open source projects. That's a better way to produce large-scale software, IMHO.

tags: #bash #programming #c++ #linux #shell #vim

In this part of the series, I will describe my bash setup, as I promised at the end of the last part of the series.

Also, I finally ordered my new machine! I will, of course, show you some facts about the machine and as soon as all parts have arrived, I will publish an article about building the machine etc!

But first, the bash setup. If you've read the last part of the series, this won't be that special for you. The approach is similar, but not that complex, of course.

So first, I had to add a new subdirectory in my ~/config/nixos/ directory. I named it programs, as all program configuration should go there. Inside this directory there is a directory named bash. Inside these directories there are the normal default.nix files.

The programs/default.nix file looks like this:

{
    programs.bash = import ./bash/default.nix;
}

So nothing special here. The programs/bash/default.nix file looks almost similar:

{
    shellAliases            = import ./aliases.nix
    enableCompletion        = true;
    promptInit              = builtins.readFile ./prompt.sh;
    interactiveShellInit    = builtins.readFile ./functions.sh;
}

Here I import the aliases, which are specified in pure nix. I also enable the completion for bash and I read the prompt.sh and functions.sh file which are located in the same directory. These files are normal bash scripts.

And that's basically it! Nothing complicated here, as you see! Of course, you can still provide your normal ~/.bashrc file and define your stuff here, but for a system-wide bash configuration, this is just awesome! Your bash setup gets compiled into your system, which means when going back to a previous configuration, the bash configuration goes back to! I really like that! And, of course, you should also be able to ship your bash configuration to a remote host. But I'm not sure about this one.


I also managed to get my next package into the luakit repository: luakit! I finally packaged luakit for nixos. It is not battle-tested yet, but as luakit will be my next browser, I will battle-test it as soon as I'm on NixOS myself!


Well, this article was rather short, but I have nothing more to tell you right now. Maybe next week, if I managed to build my machine until then!

Stay tuned! tags: #linux #nixos