I'm trying so set up a NixOS VM for code development in haskell, and got into troubles with the basic installation of both xmonad and emacs. The relevant part of my /etc/nixos/configuration.nix is
environment.systemPackages = with pkgs; [
emacs
emacs24Packages.haskellMode
xlibs.xmessage
haskellPackages.haskellPlatform.ghc
haskellPackages.xmobar
haskellPackages.xmonad
haskellPackages.xmonadContrib
haskellPackages.xmonadExtras
];
xmonad: when I try to compile the code, xmonad complains that it couldn't find the module XMonad.Util.EZConfig.
Compiling xmonad.hs with ghc is ok, and I'm also able to load the module into ghci.
On the #nixos channel, I was told to use the function ghcWithPackages, but I wasn't able to correct the problem. Moreover, I'd like to understand why there is this problem in the first place, as it seems to me that this is a very simple use case. A minimal xmonad.hs with which I have the problem is:
import XMonad
import XMonad.Util.EZConfig
main = xmonad $ defaultConfig
{ modMask = mod4Mask
, terminal = "konsole"
}
`additionalKeysP`
[ ("M-e", spawn "emacs")
, ("M-f", spawn "firefox")
]
emacs: after the installation of the package haskellmode (look at the configuration.nix above), I'm not able to enter haskell-mode in emacs.
I put together these problems as I suspect they're both caused by a fundamental incomprehension of something on my behalf, so the cause may be common.
just add
windowManager.xmonad.enableContribAndExtras = true;
to
/etc/nixos/configuration.nix
Then start xmonad the usual way through your .xsession file
I can't add comment for now... But I think it's a problem with cabal local and global repositories.
As I see, "Nix allows users to install packages without requiring root privileges, and provides each user with its own view of the set of installed packages. Multiple versions of a program or library can be installed at the same time. Package upgrades are atomic and can be rolled back."
Maybe you can use ghc-pkg list to see if, in root and normal user, the packages are well installed.
I am unsure why you're unable to compile that... I can't offer a solution, but personally, I am able to compile my XMonad config which includes
import XMonad.Util.EZConfig
This is the relevant lines in my configuration.
environment.systemPackages = with pkgs; [
haskellPackages.xmobar
haskellPackages.xmonad
haskellPackages.xmonad-contrib
haskellPackages.xmonad-extras
];
programs.dconf.enable = true;
services = {
dbus = {
enable = true;
packages = [ pkgs.dconf ];
};
xserver = {
enable = true;
libinput = {
enable = true;
touchpad.disableWhileTyping = true;
};
serverLayoutSection = ''
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
'';
displayManager = {
defaultSession = "none+xmonad";
lightdm.enable = true;
lightdm.greeters.mini.enable = true;
};
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
};
xkbOptions = "caps:ctrl_modifier";
};
};
env = {
XMONAD_CONFIG_DIR = "$XDG_CONFIG_HOME/xmonad";
XMONAD_CACHE_DIR = "$XDG_CONFIG_HOME/xmonad";
XMONAD_DATA_DIR = "$XDG_CONFIG_HOME/xmonad";
};
As someone pointed out, it might be because you don't have the line:
enableContribAndExtras = true;
I posted my configuration also so you could see how this would tie into a more extensive configuration, in this case for lightdm.
Related
I am trying to utilize NVIM's built-in LSPs. While I've been able to implement the LSP for css and python, I haven't been successful with javascript and html.
I installed the LSPs with
:LspInstall <LSP>
Here's how I'm loading the LSPs:
packadd nvim-lspconfig
packadd completion-nvim
:lua << EOF
local nvim_lsp = require('nvim_lsp')
local on_attach = function(_, bufnr)
require('completion').on_attach()
local opts = { noremap=true, silent=true }
end
local servers = {'tsserver', 'cssls', 'html', 'pyls'}
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
on_attach = on_attach
}
print("lsp istalled -", lsp)
end
EOF
:LspInstallInfo shows:
{
cssls = {
bin_dir = "~/.cache/nvim/nvim_lsp/cssls/node_modules/.bin",
binaries = {
["css-languageserver"] = "~/.cache/nvim/nvim_lsp/cssls/node_modules/.bin/css-languageserver"
},
install_dir = "~/.cache/nvim/nvim_lsp/cssls",
is_installed = true
},
html = {
bin_dir = "~/.cache/nvim/nvim_lsp/html/node_modules/.bin",
binaries = {
["html-languageserver"] = "~/.cache/nvim/nvim_lsp/html/node_modules/.bin/html-languageserver"
},
install_dir = "~/.cache/nvim/nvim_lsp/html",
is_installed = true
},
tsserver = {
bin_dir = "~/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin",
binaries = {
["typescript-language-server"] = "~/.cache/nvim/nvim_lsp/tsserver/node_modules/.bin/typescript
-language-server"
},
install_dir = "~/.cache/nvim/nvim_lsp/tsserver",
is_installed = true
}
}
They seem to be installed and the LSPs for *.css and *.py work fine.
When I open a *.js, *.ts, or *.html file I get the same response with the :LspInstallInfo command. However, I don't think the LSP is active because I do not receive any warning or error messages regarless of what I type.
I've tried loading the LSP different ways, including:
require'nvim_lsp'.tsserver.setup{}
require'nvim_lsp'.html.setup{}
I came across a post about installing typescript and I did, but it didn't seem to have any effect.
I've deactivated all of the other plugins and had the same results.
After installation, you should take consider root_dir. So if you don't have a matching root directory LSP doesn't launch.
In order to automatically launch a language server, lspconfig
searches up the directory tree from your current buffer to find a file
matching the root_dir pattern defined in each server's configuration.
For pyright, this is any directory containing ".git", "setup.py",
"setup.cfg", "pyproject.toml", or "requirements.txt").
Language servers require each project to have a root in order to
provide completion and search across symbols that may not be defined
in your current file, and to avoid having to index your entire
filesystem on each startup.
But if you want to launch LSP in any directory, you can use something like this for Javscript:
require'lspconfig'.tsserver.setup{
filetypes = { "typescript", "typescriptreact", "typescript.tsx" },
root_dir = function() return vim.loop.cwd() end -- run lsp for javascript in any directory
}
I was working on setting up neovim 0.5 today and landed up here looking for something else related to LSP. Anyho, I do have a working setup; here's a brief:
Install neovim nightly (>= 0.5 version)
Install nvim-lspconfig package (I used vim-plug)
Install tsserver: npm i -g typescript-language-server
Add setup in init.vim (remove EOF lines if init.lua):
lua << EOF
require'lspconfig'.tsserver.setup{}
EOF
Restart neovim
I noticed you're using commands like LspInstall & LspInstallInfo, but they are not present in my setup. I'm afraid I cannot comment of why they it work as expected.
LSP by itself doesn't show autocompletion. Have to use another plugin. I am getting good results with completion-nvim
This is a good reference : neovim-and-its-built-in-language-server-protocol
Oh, do give :help lsp a read if you haven't already. Cheers!
I'm trying to setup withHoogle in my default.nix, but I'm getting this error:
developPackage, error: attempt to call something which is not a function but a set(at line 26).
Here is my default.nix code:
let
pkgs = import <nixpkgs> {};
compilerVersion = "ghc865";
compiler = pkgs.haskell.packages."${compilerVersion}";
in
compiler.developPackage
{
# returnShellEnv = false;
root = ./.;
# source-overrides = {};
modifier = drv:
let pkg = pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
[
cabal-install
cabal2nix
ghcid
control
text
brick
]);
in pkg // {
env = (pkg.env { withHoogle = true; }).overrideAttrs (old: {
shellHook =
''
export PS1='\n\[\033[1;32m\][\[\e]0;nix-shell: \W\a\]nix-shell:/\W]\$ \[\033[0m\]'
'';
});
};
}
I had a similar error message when trying to nix-build a seemingly correct derivation (default.nix).
Eventually I found out using the --show-trace parameter to nix-build, that the error lie in an overlay I had in my user's ~/.config/nixpkgs/overlays directory lying around.
HTH
I'm trying to override the stable nvidia package from my configuration.nix from nvidia driver 410 to 390, however, it doesn't seem to work using the override config below.
I am enabling the driver using the services.xserver.videoDrivers = [ "nvidia" ] option and am subscribed to the unstable channel.
configuration.nix:
nixpkgs.config = {
allowUnfree = true;
packageOverrides = super: let self = super.pkgs; in
{
linuxPackages = super.linuxPackages_latest.extend (self: super: {
nvidiaPackages = super.nvidiaPackages // {
stable = super.nvidiaPackages.stable_390;
};
});
};
};
I also tried changing from super to self in the following line:
stable = super.nvidiaPackages.stable_390;
But this doesn't have any affect either.
From what I've been able to figure out, you'll need to override both the linux packages and nvidia_x11 in the core package set. If I didn't, I encountered a silent fallback to the default nvidia drivers.
The following is an example that is less fine-grained than your attempt. My thinking was that there was a possibility of a mismatch between kernel dependencies used to build and loaded at runtime, so I instead swapped out the entire linuxPackage set.
At present (01/10/2019), nvidia 410.7x is broken (see Issue 53708). So I've pinned my configuration to the last commit with nvidia 410.6x. For more information on pinning nixpkgs, see the wiki page. You can still pin against master and add an unstable namespace to your package set without interfering with the kernel.
{ config, pkgs, nixpkgs, ... }:
let
# get the last working revision with nvidia 410.x
nixos-unstable-pinned = import (builtins.fetchTarball {
name = "nixos-unstable_nvidia-410-66_2018-11-03";
url = https://github.com/nixos/nixpkgs/archive/bf084e0ed7a625b50b1b0f42b98358dfa23326ee.tar.gz;
sha256 = "0w05cw9s2pa07vqy21ack7g7983ig67lhwkdn24bzah3z49c2d8k";
}) { };
# We'll use this twice
pinnedKernelPackages = nixos-unstable-pinned.linuxPackages_latest;
in
{
# allow nvidia drivers to be loaded
nixpkgs.config.allowUnfree = true;
nixpkgs.config.packageOverrides = pkgs: {
# swap out all of the linux packages
linuxPackages_latest = pinnedKernelPackages;
# make sure x11 will use the correct package as well
nvidia_x11 = nixos-unstable-pinned.nvidia_x11;
};
# line up your kernel packages at boot
boot.kernelPackages = pinnedKernelPackages;
}
Hope this helps!
When I use pulp build -O -t html/main.js and then pulp build -O -I test -m Test.Main -t html/testmain.js (i.e. building main and test) I get two different js output. In the former case, the format is
// Generated by psc-bundle 0.8.2.0
var PS = { };
(function(exports) {
// Generated by psc version 0.8.2.0
"use strict";
var Prelude = require("../Prelude");
var Control_Monad_Eff = require("../Control.Monad.Eff");
exports["main"] = main;
})(PS["Main"] = PS["Main"] || {});
PS["Main"].main();
Please note the require. In the latter case, the require is not in place at all
// Generated by psc-bundle 0.8.2.0
var PS = { };
(function(exports) {
/* global exports */
"use strict";
exports.concatArray = function (xs) {
return function (ys) {
return xs.concat(ys);
};
};
exports.showNumberImpl = function (n) {
/* jshint bitwise: false */
return n === (n | 0) ? n + ".0" : n.toString();
};
})(PS["Prelude"] = PS["Prelude"] || {});
(function(exports) {
// Generated by psc version 0.8.2.0
"use strict";
var $foreign = PS["Prelude"];
var Semigroupoid = function (compose) {
this.compose = compose;
};
Both examples are shorten, but the point is that require is used in the first time, while not used in the second time.
The issue is that I am not able to run the version using require in the browser due to this error
ReferenceError: require is not defined
When I included require.js into page, I got this error
Error: Module name "../Prelude" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
Thus my question is, what can be done to run the first case in browser.
My guess would be that this comes from running builds with different --require-path options; once with the old default, which was an empty string, and once with ../. This would lead to psc-bundle not realising it needed to include Prelude and Control.Monad.Eff properly in the first case. psc-bundle should replace those require calls with references to the other modules, so that the code works in browsers.
There are a few different ways this can happen, and the compiler has been updated now in a way that should make the probability of this happening again much lower, so I wouldn't spend too much time worrying about exactly how this has occurred.
If none of the above makes any sense to you, don't worry; I think you just need to do the following to fix this:
Update to the latest version of psc (0.8.3 changed the --require-path default to ../, so any version after 0.8.3 should do, but you will want the latest version in most cases)
Delete your output directory
Compile everything again.
You probably need to use the --browserify option to build the first case for the browser.
Using the official traceur module, is it possible to set the default options for compile and require?
For example, this code works:
var traceur = require('traceur');
console.log(
traceur.compile('{ let x = 1; }', { experimental:true }).js
);
Now if I remove traceur.compile's 2nd argument (the options object):
console.log(
traceur.compile('{ let x = 1; }').js
);
Traceur will throw an error as the blockBinding option is not enabled. Is there any way to change the default options, in order to compile files without always passing an options object?
My main concern, apart from applying the DRY principle, is getting the traceur.require function to compile files with customized options -- as far as I can see, traceur.require and traceur.require.makeDefault() do not even take an options argument.
For instance, considering this code sample:
require('traceur').require('./index');
And this piece of code:
require('traceur').require.makeDefault();
require('./index');
Is there any way to compile the required file with the experimental option enabled?
Preferably by altering the default options, as I cannot see any other viable way.
Using Node 0.10.29 and Traceur 0.0.49.
Here's a full example of what I'd like to achieve.
bootstrap.js (entry point):
var traceur = require('traceur');
traceur.options.experimental = true;
traceur.require.makeDefault();
require('./index');
index.js:
import {x} from './lib';
// using a block binding in order to check
// whether this file was compiled with experimental features enabled
{
let y = x;
console.log(y);
}
lib.js:
export var x = (() => {
if (true) {
// should be compiled with experimental features enabled too
let x = 1;
return x;
}
})();
Expected console output: 1
traceur.options.experimental=true serves as a setter which enables the experimental features in the traceur.options object, but unfortunately traceur.options does not seem to affect traceur.compile nor traceur.require as far as I can see.
The Using Traceur with Node.js Wiki page does not mention anything about compiling options. The Options for Compiling page does not mention the Traceur API in Node.js, in fact, I cannot find any documentation about the Traceur API in Node.js.
FabrÃcio Matté ;-) added support for giving the default options to makeDefault(), see
https://github.com/google/traceur-compiler/blob/master/src/node/require.js#L58
A separate bug with the option experimental was fixed today, 16JUL14.