{"action":"created","issue":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/19031","repository_url":"https://api.github.com/repos/NixOS/nixpkgs","labels_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/19031/labels{/name}","comments_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/19031/comments","events_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/19031/events","html_url":"https://github.com/NixOS/nixpkgs/pull/19031","id":179732845,"number":19031,"title":"amazon ec2 and ami fixes","user":{"login":"matejc","id":854770,"avatar_url":"https://avatars.githubusercontent.com/u/854770?v=3","gravatar_id":"","url":"https://api.github.com/users/matejc","html_url":"https://github.com/matejc","followers_url":"https://api.github.com/users/matejc/followers","following_url":"https://api.github.com/users/matejc/following{/other_user}","gists_url":"https://api.github.com/users/matejc/gists{/gist_id}","starred_url":"https://api.github.com/users/matejc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matejc/subscriptions","organizations_url":"https://api.github.com/users/matejc/orgs","repos_url":"https://api.github.com/users/matejc/repos","events_url":"https://api.github.com/users/matejc/events{/privacy}","received_events_url":"https://api.github.com/users/matejc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-09-28T10:13:40Z","updated_at":"2016-10-09T23:25:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NixOS/nixpkgs/pulls/19031","html_url":"https://github.com/NixOS/nixpkgs/pull/19031","diff_url":"https://github.com/NixOS/nixpkgs/pull/19031.diff","patch_url":"https://github.com/NixOS/nixpkgs/pull/19031.patch"},"body":"###### Motivation for this change\r\n\r\nLaunching EC2 instance from AMI image has a few problems, I fixed 3:\r\n\r\n- I temporarily set 8.8.8.8 name server (it will be automagically set later to correct entries) so that nixos.org and cache domains are resolved during stage-2-init, that is rebuilding from user-data (nixos configuration)\r\nif 8.8.8.8 is not acceptable, we can use something like: `dig | grep SERVER: | awk -F# '{print $1}' | awk -F': ' '{print $2}'` which I found on some stack overflow post and it worked in my debugging process.\r\nPlease advise on better solutions.\r\nPS: this fixes https://github.com/NixOS/nixpkgs/issues/19010\r\n\r\n- set `NIX_PATH=nixpkgs=/path/to/nixpkgs:....` instead of `NIX_PATH=/path/to/nixpkgs:....` which fails because rebuild searches for `nixpkgs` folder in `/path/to/nixpkgs` which is non existant at least in latest master/unstable, prefixing nixpkgs path with `nixpkgs=` fixes this\r\n\r\n- fetch meta-data on every boot, because at least `user-data` and `hostname` files can have dynamic content\r\n\r\nProcedure to check:\r\n\r\ntemporarily change these variables to make build and upload process of AMI faster in the `./nixpkgs/nixos/maintainers/scripts/ec2/create-amis.sh`\r\n```\r\ntypes=\"hvm\"\r\nstores=\"ebs\"\r\nregions=\"eu-central-1\"\r\n```\r\n\r\nthen build and upload AMI\r\n```\r\n# dependencies of create-amis.sh\r\nnix-env -iA awscli\r\nnix-env -iA qemu\r\nnix-env -iA ec2_api_tools\r\nnix-env -iA jq\r\n\r\nexport AWS_ACCOUNT=\"#####\"\r\nexport AWS_ACCESS_KEY_ID=\"##########\"\r\nexport AWS_SECRET_ACCESS_KEY=\"###########\"\r\nexport NIX_PATH=\"nixpkgs=/home/matejc/workarea/gatehub/ec2/nixpkgs\"\r\n\r\n./nixpkgs/nixos/maintainers/scripts/ec2/create-amis.sh\r\n```\r\n\r\nthen launch instance with user-data:\r\n```\r\n### https://github.com/matejc/nixpkgs/archive/aws-fixes.tar.gz nixos\r\n\r\n{\r\n  imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];\r\n  ec2.hvm = true;\r\n  security.sudo.wheelNeedsPassword = false;\r\n  users.extraUsers.matejc =\r\n    { createHome      = true;\r\n      home            = \"/home/matejc\";\r\n      description     = \"Matej\";\r\n      extraGroups     = [ \"wheel\" ];\r\n      useDefaultShell = true;\r\n      openssh.authorizedKeys.keys = [\r\n        \"ssh-rsa ...\"\r\n      ];\r\n    };\r\n}\r\n```\r\nnote: that `https://github.com/matejc/nixpkgs/archive/aws-fixes.tar.gz` points to `aws-fixes` branch, which is revision to this pull request.\r\n\r\nthings to check: at first boot at `stage-2-init` inside `journalctl -b` should be visible rebuild procedure, then stop the instance and change user data, lets say.. add `services.redis.enable = true;` and start the instance and after booting process is done you should have redis running.\r\n\r\n###### Things done\r\n\r\n- [ ] Tested using sandboxing\r\n  ([nix.useSandbox](http://nixos.org/nixos/manual/options.html#opt-nix.useSandbox) on NixOS,\r\n    or option `build-use-sandbox` in [`nix.conf`](http://nixos.org/nix/manual/#sec-conf-file)\r\n    on non-NixOS)\r\n- Built on platform(s)\r\n   - [x] NixOS\r\n   - [ ] OS X\r\n   - [ ] Linux\r\n- [ ] Tested compilation of all pkgs that depend on this change using `nix-shell -p nox --run \"nox-review wip\"`\r\n- [x] Tested execution of all binary files (usually in `./result/bin/`)\r\n- [x] Fits [CONTRIBUTING.md](https://github.com/NixOS/nixpkgs/blob/master/.github/CONTRIBUTING.md).\r\n\r\n---\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/NixOS/nixpkgs/issues/comments/252520532","html_url":"https://github.com/NixOS/nixpkgs/pull/19031#issuecomment-252520532","issue_url":"https://api.github.com/repos/NixOS/nixpkgs/issues/19031","id":252520532,"user":{"login":"matejc","id":854770,"avatar_url":"https://avatars.githubusercontent.com/u/854770?v=3","gravatar_id":"","url":"https://api.github.com/users/matejc","html_url":"https://github.com/matejc","followers_url":"https://api.github.com/users/matejc/followers","following_url":"https://api.github.com/users/matejc/following{/other_user}","gists_url":"https://api.github.com/users/matejc/gists{/gist_id}","starred_url":"https://api.github.com/users/matejc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matejc/subscriptions","organizations_url":"https://api.github.com/users/matejc/orgs","repos_url":"https://api.github.com/users/matejc/repos","events_url":"https://api.github.com/users/matejc/events{/privacy}","received_events_url":"https://api.github.com/users/matejc/received_events","type":"User","site_admin":false},"created_at":"2016-10-09T23:25:58Z","updated_at":"2016-10-09T23:25:58Z","body":"I have seen this line before...\r\n```\r\nln: failed to create symbolic link '/root/.nix-defexpr/channels/channels': Read-only file system\r\n```\r\nReboot of the instance helped, the second time around it got the configuration and rebuild was triggered, I haven't reported this because it happened only few times during my debugging, at the time... I have literally ran 6 instances and even more tries per one ec2 instance.\r\n\r\nTo fix this... my guess would be to check, where the channels link is being created in bash code, It might be outside the scope of this pull request, because it might be in nix-channel command, according to the output"}}
{"actor":{"display_login":"matejc"}}