From c6662575a085242fd216729ee3429a8b69f91f73 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Sun, 27 Oct 2019 12:43:49 -0700 Subject: use a standard buildNixOS function --- com/influencedbybooks.nix | 42 -------------------- com/influencedbybooks/service.nix | 42 ++++++++++++++++++++ com/simatime.nix | 82 +++++++++++++++++---------------------- com/simatime/dev.nix | 4 +- default.nix | 74 +++++++++++------------------------ 5 files changed, 103 insertions(+), 141 deletions(-) delete mode 100644 com/influencedbybooks.nix create mode 100644 com/influencedbybooks/service.nix diff --git a/com/influencedbybooks.nix b/com/influencedbybooks.nix deleted file mode 100644 index f9d0f36..0000000 --- a/com/influencedbybooks.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ options -, lib -, config -, pkgs -, modulesPath -}: - -let - cfg = config.services.ibb; -in -{ - options.services.ibb = { - enable = lib.mkEnableOption "Enable the IBB service"; - port = lib.mkOption { - type = lib.types.string; - default = "3000"; - description = '' - The port on which IBB will listen for - incoming HTTP traffic. - ''; - }; - }; - config = lib.mkIf cfg.enable { - systemd.services.ibb = { - path = with pkgs; [ ibb bash ]; - wantedBy = [ "multi-user.target" ]; - script = '' - PORT=${cfg.port} ./bin/ibb - ''; - description = '' - Influenced By Books website - ''; - serviceConfig = { - WorkingDirectory = pkgs.ibb; - KillSignal = "INT"; - Type = "simple"; - Restart = "on-abort"; - RestartSec = "10"; - }; - }; - }; -} diff --git a/com/influencedbybooks/service.nix b/com/influencedbybooks/service.nix new file mode 100644 index 0000000..f9d0f36 --- /dev/null +++ b/com/influencedbybooks/service.nix @@ -0,0 +1,42 @@ +{ options +, lib +, config +, pkgs +, modulesPath +}: + +let + cfg = config.services.ibb; +in +{ + options.services.ibb = { + enable = lib.mkEnableOption "Enable the IBB service"; + port = lib.mkOption { + type = lib.types.string; + default = "3000"; + description = '' + The port on which IBB will listen for + incoming HTTP traffic. + ''; + }; + }; + config = lib.mkIf cfg.enable { + systemd.services.ibb = { + path = with pkgs; [ ibb bash ]; + wantedBy = [ "multi-user.target" ]; + script = '' + PORT=${cfg.port} ./bin/ibb + ''; + description = '' + Influenced By Books website + ''; + serviceConfig = { + WorkingDirectory = pkgs.ibb; + KillSignal = "INT"; + Type = "simple"; + Restart = "on-abort"; + RestartSec = "10"; + }; + }; + }; +} diff --git a/com/simatime.nix b/com/simatime.nix index e26219a..d67c756 100644 --- a/com/simatime.nix +++ b/com/simatime.nix @@ -1,4 +1,4 @@ -{ nixos }: +{ buildNixOS }: /* @@ -11,50 +11,40 @@ stuff deployed. */ -{ - service = - let - nixos-mailserver = builtins.fetchTarball { - url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.2.1/nixos-mailserver-v2.2.1.tar.gz"; - sha256 = "03d49v8qnid9g9rha0wg2z6vic06mhp0b049s3whccn1axvs2zzx"; - }; - in nixos { - system = "x86_64-linux"; - configuration = { - imports = [ - ./simatime/hardware.nix - ./simatime/networking.nix - - # common infra - ./simatime/users.nix - ./simatime/packages.nix - - # configured modules - ./simatime/git.nix - ./simatime/mail.nix - ./simatime/web.nix - ./simatime/znc.nix - - # third party - nixos-mailserver - ]; - - nixpkgs.config.allowUnfree = true; - - programs.mosh = { - enable = true; - withUtempter = true; - }; - - services.openssh = { - enable = true; - passwordAuthentication = false; - }; - - security.sudo.wheelNeedsPassword = true; - boot.cleanTmpDir = true; - }; +let + nixos-mailserver = builtins.fetchTarball { + url = "https://gitlab.com/simple-nixos-mailserver/nixos-mailserver/-/archive/v2.2.1/nixos-mailserver-v2.2.1.tar.gz"; + sha256 = "03d49v8qnid9g9rha0wg2z6vic06mhp0b049s3whccn1axvs2zzx"; + }; +in buildNixOS { + system = "x86_64-linux"; + configuration = { + imports = [ + ./simatime/hardware.nix + ./simatime/networking.nix + # common infra + ./simatime/users.nix + ./simatime/packages.nix + # configured modules + ./simatime/git.nix + ./simatime/mail.nix + ./simatime/web.nix + ./simatime/znc.nix + # third party + nixos-mailserver + ]; + nixpkgs.config.allowUnfree = true; + programs.mosh = { + enable = true; + withUtempter = true; }; - - dev = import ./simatime/dev.nix { inherit nixos; }; + services.openssh = { + enable = true; + passwordAuthentication = false; + }; + security.sudo.wheelNeedsPassword = true; + boot.cleanTmpDir = true; + }; +} // { + dev = import ./simatime/dev.nix { inherit buildNixOS; }; } diff --git a/com/simatime/dev.nix b/com/simatime/dev.nix index a45a92b..b2ed3b0 100644 --- a/com/simatime/dev.nix +++ b/com/simatime/dev.nix @@ -1,4 +1,4 @@ -{ nixos }: +{ buildNixOS }: /* @@ -7,7 +7,7 @@ Mountain View. */ -nixos { +buildNixOS { system = "x86_64-linux"; configuration = { imports = [ diff --git a/default.nix b/default.nix index 55f96e7..e3d3ca1 100644 --- a/default.nix +++ b/default.nix @@ -2,58 +2,30 @@ let nixpkgs-tar = builtins.fetchTarball (import ./nixpkgs.nix); nixpkgs = import "${nixpkgs-tar}" {}; nixos = import "${nixpkgs-tar}/nixos"; + # TODO(bsima): buildNixOS should be split into multiple functions that each + # return one thing, instead of a single function that returns multiple things + buildNixOS = opts: let full = (nixos opts); in { + system = full.system; + vm = full.vm; + }; - # a common build function - # - bild = file: - with nixpkgs; - let - pack = import file; - - depsToPackageSet = packageSet: deps: - map (s: builtins.getAttr s packageSet) deps; - - ghc844_ = pkgs.haskell.packages.ghc844.override (oldAttrs: { - overrides = with pkgs.haskell.lib; self: super: { - clay = dontCheck super.clay; - }; - }); - - ghc = ghc844_.ghcWithPackages (hp: depsToPackageSet hp - # we need hinotify for chip/make - ([ "hinotify" ] ++ pack.deps.both ++ pack.deps.apex)); - - ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: { - overrides = with pkgs.haskell.lib; self: super: { - clay = dontCheck super.clay; - http-types = dontCheck super.http-types; - tasty-quickcheck = dontCheck super.tasty-quickcheck; - scientific = dontCheck super.scientific; # takes forever - servant = dontCheck super.servant; - comonad = dontCheck super.comonad; - QuickCheck = dontCheck super.QuickCheck; - }; - }); - - ghcjs = ghcjs_.ghcWithPackages (hp: - depsToPackageSet hp (pack.deps.both ++ pack.deps.aero)); - - make = ./chip/make; - in stdenv.mkDerivation { - name = pack.name; - version = "0"; - src = ../.; - nativeBuildInputs = [ - ghc ghcjs +in { + com.simatime = import ./com/simatime.nix { inherit buildNixOS; }; + com.influencedbybooks = buildNixOS { + system = "x86_64-linux"; + configuration = { + imports = [ + ./com/influencedbybooks/service.nix + # common infra + ./com/simatime/users.nix + ./com/simatime/packages.nix ]; - strictDeps = true; - buildPhase = "${ghc}/bin/runhaskell ${make} ${pack.name}"; - installPhase = '' - mkdir -p $out/bin - cp bild/${pack.name} $out/bin/${pack.name} - ''; + nixpkgs.config.allowUnfree = true; + services.openssh = { + enable = true; + passwordAuthentication = false; + }; + security.sudo.wheelNeedsPassword = true; + boot.cleanTmpDir = true; }; -in { - com.simatime = import ./com/simatime.nix { inherit nixos; }; - com.influencedbybooks = import ./com/influencedbybooks/default.nix {}; } -- cgit v1.2.3