Skip to content

Commit

Permalink
use nix and nixos version from released-nixpkgs input
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Jun 8, 2020
1 parent 3eee85b commit e50a6f7
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 113 deletions.
21 changes: 9 additions & 12 deletions Makefile
Expand Up @@ -81,27 +81,24 @@ favicon.ico: favicon.png
%-small.png: %.png
convert -resize 200 $< $@

%.html: %.tt layout.tt common.tt nix-release.tt nixos-release.tt
%.html: %.tt layout.tt common.tt
tpage \
--pre_chomp --post_chomp \
--define root=$(ROOT) \
--define fileName=$< \
--define nixosAmis=$(NIXOS_AMIS) \
--pre_process=nix-release.tt --pre_process=nixos-release.tt --pre_process=common.tt \
--define latestNixVersion=$(NIX_VERSION) \
--define latestNixOSSeries=$(NIXOS_SERIES) \
--pre_process=common.tt \
$< > $@.tmp
xmllint --nonet --noout $@.tmp
mv $@.tmp $@

# FIXME: hacky. The channel generator should put up a JSON file.
nixos-release.tt:
uri=$$(curl --fail --silent -o /dev/null -w %{redirect_url} https://nixos.org/channels/nixos-${NIXOS_SERIES}); \
version=$$(echo $$uri | sed 's|.*/nixos-||'); \
echo "[%- latestNixOSSeries = \"${NIXOS_SERIES}\"; -%]" > $@

%: %.in common.tt nix-release.tt
%: %.in common.tt
echo $$PATH
tpage \
--pre_process=nix-release.tt --pre_process=common.tt $< > $@.tmp
--define latestNixVersion=$(NIX_VERSION) \
--pre_process=common.tt $< > $@.tmp
mv $@.tmp $@

news.html: all-news.xhtml
Expand Down Expand Up @@ -130,8 +127,8 @@ blogs.json: blogs.xml
mv $@.tmp $@

ifeq ($(UPDATE), 1)
.PHONY: blogs.xml nixos-release.tt
update: blogs.xml nixos-release.tt
.PHONY: blogs.xml
update: blogs.xml
@true
endif

Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

193 changes: 98 additions & 95 deletions flake.nix
Expand Up @@ -9,105 +9,108 @@
inputs.nix-pills = { url = "github:NixOS/nix-pills"; flake = false; };

outputs = { self, nixpkgs, released-nixpkgs, nix-pills }:
with import nixpkgs { system = "x86_64-linux"; };
rec {

checks.x86_64-linux.build = defaultPackage.x86_64-linux;

packages.x86_64-linux = {

packagesExplorer = import ./packages-explorer nixpkgs;

nixosAmis = writeText "ec2-amis.json"
(builtins.toJSON (
import (released-nixpkgs + "/nixos/modules/virtualisation/ec2-amis.nix")));

nixPills = import nix-pills {
inherit pkgs;
revCount = nix-pills.lastModifiedDate; # FIXME
shortRev = nix-pills.shortRev;
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
released-pkgs = import released-nixpkgs { system = "x86_64-linux"; };
in rec {
checks.x86_64-linux.build = defaultPackage.x86_64-linux;

packages.x86_64-linux = {

packagesExplorer = import ./packages-explorer nixpkgs;

nixosAmis = pkgs.writeText "ec2-amis.json"
(builtins.toJSON (
import (released-nixpkgs + "/nixos/modules/virtualisation/ec2-amis.nix")));

nixPills = import nix-pills {
inherit pkgs;
revCount = nix-pills.lastModifiedDate; # FIXME
shortRev = nix-pills.shortRev;
};

homepage = pkgs.stdenv.mkDerivation {
name = "nixos-homepage-${self.lastModifiedDate}";

src = self;

enableParallelBuilding = true;

buildInputs = with pkgs; [
fd
libxslt
libxml2
perl
perlPackages.JSON
perlPackages.XMLSimple
perlPackages.TemplateToolkit
perlPackages.TemplatePluginJSONEscape
perlPackages.TemplatePluginIOAll
perlPackages.AppConfig
pkgs.nix
imagemagick
xhtml1
jq
python3
python3Packages.click
python3Packages.colorama
entr
];

preBuild = ''
export NIX_DB_DIR=$TMPDIR
export NIX_STATE_DIR=$TMPDIR
'';

makeFlags =
[ "NIX_VERSION=${released-pkgs.lib.getVersion released-pkgs.nix.name}"
"NIXOS_SERIES=${released-pkgs.lib.trivial.release}"
"NIX_MANUAL_IN=${released-pkgs.nix.doc}/share/doc/nix/manual"
"NIXOS_MANUAL_IN=${released-nixpkgs.htmlDocs.nixosManual}"
"NIXPKGS_MANUAL_IN=${released-nixpkgs.htmlDocs.nixpkgsManual}"
"NIXOS_AMIS=${packages.x86_64-linux.nixosAmis}"
"PACKAGES_EXPLORER=${packages.x86_64-linux.packagesExplorer}/bundle.js"
"NIX_PILLS_MANUAL_IN=${packages.x86_64-linux.nixPills}/share/doc/nix-pills"
];

installPhase = ''
mkdir $out
cp -prd . $out/
'';

shellHook = ''
export NIX_VERSION="${released-pkgs.lib.getVersion released-pkgs.nix.name}"
export NIXOS_SERIES="${released-pkgs.lib.trivial.release}"
export NIX_MANUAL_IN="${released-pkgs.nix.doc}/share/doc/nix/manual"
export NIXOS_MANUAL_IN="${released-nixpkgs.htmlDocs.nixosManual}"
export NIXPKGS_MANUAL_IN="${released-nixpkgs.htmlDocs.nixpkgsManual}"
export NIXOS_AMIS="${packages.x86_64-linux.nixosAmis}"
export PACKAGES_EXPLORER="${packages.x86_64-linux.packagesExplorer}/bundle.js"
export NIX_PILLS_MANUAL_IN="${packages.x86_64-linux.nixPills}/share/doc/nix-pills"
'';
};
};

homepage = stdenv.mkDerivation {
name = "nixos-homepage-${self.lastModifiedDate}";

src = self;

enableParallelBuilding = true;

buildInputs =
[ fd
libxslt
libxml2
perl
perlPackages.JSON
perlPackages.XMLSimple
perlPackages.TemplateToolkit
perlPackages.TemplatePluginJSONEscape
perlPackages.TemplatePluginIOAll
perlPackages.AppConfig
pkgs.nix
imagemagick
xhtml1
jq
python3
python3Packages.click
python3Packages.colorama
entr
];

preBuild = ''
export NIX_DB_DIR=$TMPDIR
export NIX_STATE_DIR=$TMPDIR
'';

makeFlags =
[ "NIX_MANUAL_IN=${released-nixpkgs.legacyPackages.x86_64-linux.nix.doc}/share/doc/nix/manual"
"NIXOS_MANUAL_IN=${released-nixpkgs.htmlDocs.nixosManual}"
"NIXPKGS_MANUAL_IN=${released-nixpkgs.htmlDocs.nixpkgsManual}"
"NIXOS_AMIS=${packages.x86_64-linux.nixosAmis}"
"PACKAGES_EXPLORER=${packages.x86_64-linux.packagesExplorer}/bundle.js"
"NIX_PILLS_MANUAL_IN=${packages.x86_64-linux.nixPills}/share/doc/nix-pills"
defaultPackage.x86_64-linux = packages.x86_64-linux.homepage;

nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[ ({ lib, ... }:
{ system.configurationRevision = lib.mkIf (self ? rev) self.rev;
boot.isContainer = true;
networking.useDHCP = false;
networking.firewall.allowedTCPPorts = [ 80 ];
services.httpd = {
enable = true;
adminAddr = "admin@example.org";
virtualHosts.default = {
documentRoot = self.packages.x86_64-linux.homepage;
};
};
})
];

installPhase = ''
mkdir $out
cp -prd . $out/
'';

shellHook = ''
export NIX_MANUAL_IN="${released-nixpkgs.legacyPackages.x86_64-linux.nix.doc}/share/doc/nix/manual"
export NIXOS_MANUAL_IN="${released-nixpkgs.htmlDocs.nixosManual}"
export NIXPKGS_MANUAL_IN="${released-nixpkgs.htmlDocs.nixpkgsManual}"
export NIXOS_AMIS="${packages.x86_64-linux.nixosAmis}"
export PACKAGES_EXPLORER="${packages.x86_64-linux.packagesExplorer}/bundle.js"
export NIX_PILLS_MANUAL_IN="${packages.x86_64-linux.nixPills}/share/doc/nix-pills"
'';
};


};

defaultPackage.x86_64-linux = packages.x86_64-linux.homepage;

nixosConfigurations.container = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules =
[ ({ lib, ... }:
{ system.configurationRevision = lib.mkIf (self ? rev) self.rev;
boot.isContainer = true;
networking.useDHCP = false;
networking.firewall.allowedTCPPorts = [ 80 ];
services.httpd = {
enable = true;
adminAddr = "admin@example.org";
virtualHosts.default = {
documentRoot = self.packages.x86_64-linux.homepage;
};
};
})
];
};

};
}
3 changes: 0 additions & 3 deletions nix-release.tt

This file was deleted.

0 comments on commit e50a6f7

Please sign in to comment.