Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get disnix to work on Ubuntu 14.04 LTS #5

Open
matthiasbeyer opened this issue Apr 7, 2016 · 3 comments
Open

Can't get disnix to work on Ubuntu 14.04 LTS #5

matthiasbeyer opened this issue Apr 7, 2016 · 3 comments

Comments

@matthiasbeyer
Copy link

So I installed things on a Ubuntu 14.04 LTS VM:

sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install htop curl -y

curl https://nixos.org/nix/install | sh
. /home/clouduser/.nix-profile/etc/profile.d/nix.sh

nix-env -i $(nix-build -E 'with import <nixpkgs> {}; dysnomia.override { jobTemplate = "direct"; }')
nix-env -f '<nixpkgs>' -iA disnix

sudo cp /nix/var/nix/profiles/default/etc/dbus-1/system.d/disnix.conf /etc/dbus-1/system.d/
sudo cp /nix/var/nix/profiles/default/share/doc/disnix/disnix-service.initd /etc/init.d/

sudo mv /etc/init.d/disnix-service.initd /etc/init.d/disnix
sudo chmod +x /etc/init.d/disnix

osrel() {
    cat /etc/os-release | grep -E "$1"
}

if [[ $(osrel "^NAME=" | grep Debian) ]]; then
    sudo systemctl daemon-reload
elsif [[ $(osrel "^NAME=" | grep Ubuntu) ]]; then
    if [[ $(osrel "^VERSION_ID" | cut -d "=" -f 2) =~ '"14.04"' ]];
    then
        sudo initctl reload-configuration
    else
        echo "NOT SUPPORTED: $(osrel "^VERSION_ID")"
        exit 1
    fi
fi


for n in 2 3 4 5; do
    sudo ln -s /etc/init.d/disnix-service.initd /etc/rc${n}.d/S06disnix-service;
done

sudo vim /etc/dbus-1/system.d/disnix.conf
sudo vim /etc/init.d/disnix

sudo chmod a+w /var/run
sudo /etc/init.d/disnix start
sudo /etc/init.d/disnix status

echo "DONE"

And it seems that the call to sudo /etc/init.d/disnix start somehow failed (status returns nothing and gives exit code 3).

@svanderburg thinks that the dbus name gets lost somewhere.

With this patch applied (git diff):

diff --git a/src/dbus-service/disnix-service.c b/src/dbus-service/disnix-service.c
index 288d7b9..c279524 100644
--- a/src/dbus-service/disnix-service.c
+++ b/src/dbus-service/disnix-service.c
@@ -84,6 +84,12 @@ static void on_name_acquired(GDBusConnection *connection, const gchar *name, gpo
 static void on_name_lost(GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
     g_printerr("Name lost: %s\n", name);
+
+       if (connection == NULL)
+               g_printerr("No D-Bus connection has been established!\n");
+       else
+               g_printerr("A D-Bus connection seems to have been established!\n");
+
     exit(1);
 }

I get the following output:

$ ./result/bin/disnix-service 
The Disnix service is running!
Name lost: org.nixos.disnix.Disnix
A D-Bus connection seems to have been established

So at least something seems to work.

I'm not sure where the actual error is located, though.

@svanderburg
Copy link
Owner

I installed a Ubuntu 14.04 LTS image myself and everything seems to work fine.

I suspect this is a problem lies with glib or dbus, or a combination of both, and maybe newer versions have solved it.

In my attempt, I installed the very latest versions of the packages and used the latest unstable Nixpkgs version.

@tomberek
Copy link

Happens with QEMU NixOS images as well on intial build. Works fine after a reboot.

@tomberek
Copy link

This setup helped by get to a position where disnix/dysnomia starts to work on ubuntu. I'm sure some of it isn't required, but it's a start.

#!/usr/bin/env bash                                                                                          
                                                                                                             
#Install basic stuff
sudo apt install -y curl openssh-server                                                                      
                                                                                                             
#Get Nix                                                                                                     
if ! command -v nix 2>/dev/null ; then                                                                       
    yes | bash <(curl https://nixos.org/nix/install) --daemon                                                
fi                                                                                                           
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh                                                  
                                                                                                             
# Ensure multi-user nix is in PATH                                                                           
sudo tee /etc/environment <<EOF                                                                              
PATH="/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"        
LANG="en_US.UTF-8"
EOF
sudo tee /etc/bash.bashrc <<EOF
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ];then                                   
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'                                              
fi
EOF

# Install disnix
sudo -Hi nix-env -iA nixpkgs.disnix nixpkgs.dysnomia
sudo ln -s /etc/systemd /etc/systemd-mutable
sudo cp /nix/var/nix/profiles/default/etc/dbus-1/system.d/disnix.conf /etc/dbus-1/system.d/.                 

sudo tee /etc/systemd/system/disnix.service <<EOF
[Install]
WantedBy=multi-user.target
[Unit]
After=dbus.service
[Service]
Environment=PATH=/nix/var/nix/profiles/default/bin:/bin
ExecStart=/nix/var/nix/profiles/default/bin/disnix-service                                                   
EOF

# Setup disnix requirements
sudo mkdir -p /var/log/disnix
sudo groupadd disnix || true
sudo usermod -a -G disnix $USER | true

# Start disnix service
sudo systemctl daemon-reload
sudo systemctl reload dbus
sudo systemctl enable disnix
sudo systemctl reenable disnix
sudo systemctl start disnix

# Create keys if not already made
if [ ! -f ~/.ssh/id_rsa ] ; then
    ssh-keygen -N "" -f ~/.ssh/id_rsa
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants